Popularity
3.2
Growing
Activity
2.5
Declining
29
9
4

Programming language: Go
Tags: Goroutines    

async alternatives and similar packages

Based on the "Goroutines" category

Do you think we are missing an alternative of async or a related project?

Add another 'Goroutines' Package

README

Async

Build Status codecov Go Report Card GoDoc

Provides a safe way to execute fns's functions asynchronously, recovering them in case of panic. It also provides an error stack aiming to facilitate fail causes discovery.

Usage

func InsertAsynchronously(ctx context.Context) error {
    transaction := db.Transaction().Begin()

    err := async.Run(ctx,
        func(_ context.Context) error {
            _, err := transaction.Exec(`
                INSERT INTO foo (bar)
                VALUES ('Hello')
            `)

            return err
        },

        func(_ context.Context) error {
            _, err := transaction.Exec(`
                INSERT INTO foo (bar)
                VALUES ('world')
            `)

            return err
        },

        func(_ context.Context) error {
            _, err := transaction.Exec(`
                INSERT INTO foo (bar)
                VALUES ('asynchronously!')
            `)

            return err
        },
    )

    if err != nil {
        e := transaction.Rollback()
        log.IfError(e)
        return err
    }

    return transaction.Commit()
}