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

Async

Build Status codecov Go Report Card GoDoc

Provides a safe way to execute functions asynchronously, recovering them in case of panic. It also provides an error stack aiming to facilitate fail causes discovery, and a simple way to control execution flow without WaitGroup.

Usage

var (
    user   User
    songs  []Songs
    photos []Photos
)

err := async.Run(ctx,
    func(ctx context.Context) error {
        user, err = user.Get(ctx, id)
        return err
    },
    func(ctx context.Context) error {
        songs, err = song.GetByUserID(ctx, id)
        return err
    },
    func(ctx context.Context) error {
        photos, err = photo.GetByUserID(ctx, id)
        return err
    },
)

if err != nil {
    log.Error(err)
}

You can also limit the number of asynchronous tasks

runner := async.NewRunner(tasks...).WithLimit(3)
if err := runner.Run(ctx); err != nil { 
    log.Error(e)
}
Owner
Studio Sol Comunicação Digital Ltda
Studio Sol Comunicação Digital Ltda
Similar Resources

Myretail-target-case-study - Case study assessment for Target.com

myRetail This project contains two solutions to the Target myRetail case study. The prompt is copied over to PROMPT.md for convenience, but the TLDR i

Jan 1, 2022

Generic error handling with panic, recover, and defer.

Generic error handling with panic, recover, and defer.

Aug 25, 2022

Modular C2 framework aiming to ease post exploitation for red teamers.

test.mp4 testvideo.mp4 Usage: Inside the command server you can reference beacons using either their list id or their unique id. For example if the ou

Dec 17, 2022

Wraps the normal error and provides an error that is easy to use with net/http.

Go HTTP Error Wraps the normal error and provides an error that is easy to use with net/http. Install go get -u github.com/cateiru/go-http-error Usage

Dec 20, 2021

Go concurrent-safe, goroutine-safe, thread-safe queue

Go concurrent-safe, goroutine-safe, thread-safe queue

goconcurrentqueue - Concurrent safe queues The package goconcurrentqueue offers a public interface Queue with methods for a queue. It comes with multi

Dec 31, 2022

This package provides simple graph to execute functions in a group

Introduction This package provides simple graph to execute functions in a group.

Jul 22, 2022

db-recovery is a tool for recovering MySQL data.

db-recovery is a tool for recovering MySQL data. It is used in scenarios where the database has no backup or binlog. It can parse data files and redo/undo logs to recover data.

Nov 17, 2022

DNS/DoT to DoH proxy with load-balancing, fail-over and SSL certificate management

dns-proxy Configuration Variable Example Description TLS_DOMAIN my.duckdns.org Domain name without wildcards. Used to create wildcard certificate and

Oct 26, 2022

Fail2Connect - Ban connections that fail to connect

Fail2Connect - Ban connections that fail to connect Fail2Connect is a program written in Golang. It reads log files like /var/log/openvpn.log or /var/

Jan 8, 2022

Supports the safe and convenient execution of asynchronous computations with goroutines and provides facilities for the safe retrieval of the computation results.

Rendezvous The Rendezvous library supports the safe and convenient execution of asynchronous computations with goroutines and provides facilities for

Dec 29, 2021

Kobiton-execute-test-buildkite-plugin - A Buildkite Plugin to (synchronously) execute an automated test script on Kobiton service

Kobiton Execute Test Buildkite Plugin A Buildkite Plugin to (synchronously) exec

Feb 10, 2022

Framework for performing work asynchronously, outside of the request flow

Framework for performing work asynchronously, outside of the request flow

JobRunner JobRunner is framework for performing work asynchronously, outside of the request flow. It comes with cron to schedule and queue job functio

Jan 1, 2023

Gorgonia is a library that helps facilitate machine learning in Go.

Gorgonia is a library that helps facilitate machine learning in Go.

Gorgonia is a library that helps facilitate machine learning in Go. Write and evaluate mathematical equations involving multidimensional arrays easily

Dec 30, 2022

Gorgonia is a library that helps facilitate machine learning in Go.

Gorgonia is a library that helps facilitate machine learning in Go.

Gorgonia is a library that helps facilitate machine learning in Go. Write and evaluate mathematical equations involving multidimensional arrays easily

Dec 27, 2022

Asynchronously control the different roles available in the kubernetes cluster

RBAC audit Introduction This tool allows you to asynchronously control the different roles available in the kubernetes cluster. These audits are enter

Oct 19, 2021

OC Wrapper to facilitate switch clusters quickly

Description OCS is a wrapper for openshift cli-client oc logins to facilitate switching between multiple clusters easily. Install CP binary from repo/

Jan 10, 2022

A simple CLI tool that identifies duplicate JARS in a directory. It can remove them also if desired.

Mendix Userlib Cleaner This little utility can be used to identify and clean duplicate JARs. It was created mainly for Mendix apps due to lack of form

Nov 15, 2022

Subfinder is a subdomain discovery tool that discovers valid subdomains for websites. Designed as a passive framework to be useful for bug bounties and safe for penetration testing.

Subfinder is a subdomain discovery tool that discovers valid subdomains for websites. Designed as a passive framework to be useful for bug bounties and safe for penetration testing.

Fast passive subdomain enumeration tool. Features • Install • Usage • API Setup • License • Join Discord Subfinder is a subdomain discovery tool that

Jan 4, 2023
Comments
  • runner handle panic

    runner handle panic

    It shoudle add defer safePanic(cerr) in wrapperChannel to handle panic

    // runner.go
    func wrapperChannel(ctx context.Context, task Task) chan error {
    	cerr := make(chan error, 1)
    	go func() {
    		defer safePanic(cerr)
    
    		cerr <- task(ctx)
    		close(cerr)
    	}()
    	return cerr
    }
    
    // runner_test.go
    func TestRunner_Panic(t *testing.T) {
    	ctx, cancel := context.WithTimeout(context.Background(), time.Second)
    	defer cancel()
    
    	runner := NewRunner(func(context.Context) error {
    		panic(errors.New("test panic"))
    		return nil
    	})
    	err := runner.Run(ctx)
    
    	require.Contains(t, err.Error(), "async.Run: panic test panic")
    }
    
    
  • Include task runner

    Include task runner

    Example of usage:

    runner := NewRunner(tasks...).WithLimit(3)
    err := runner.Run(ctx) 
    

    Closes https://github.com/StudioSol/async/issues/2 Closes https://github.com/StudioSol/async/issues/3

  • Include option to wait all erros finish

    Include option to wait all erros finish

    In the current version, if 3 functions is given and one of the fail, the async run will stop and return this error. The feature consists in include a flag to wait all functions finish and return all erros.

    Suggestion of signature:

    runner := async.NewRunner(tasks...).WaitErrors(true)
    err := runner.Do(ctx)
    

    The erros can be merged with the new errors package: https://golang.org/pkg/errors/#New The option %w will stack all errors in a single one.

  • Include async limit

    Include async limit

    The async.Run execute all functions in the same time. Maybe a limit parameter can help with limited asynchronous tasks.

    Suggestion of signature:

    runner := async.NewRunner(tasks...).WithLimit(5).OtherOption(foo, bar)
    err := runner.Do(ctx)
    
Hunch provides functions like: All, First, Retry, Waterfall etc., that makes asynchronous flow control more intuitive.
Hunch provides functions like: All, First, Retry, Waterfall etc., that makes asynchronous flow control more intuitive.

Hunch Hunch provides functions like: All, First, Retry, Waterfall etc., that makes asynchronous flow control more intuitive. About Hunch Go have sever

Dec 8, 2022
A sync.WaitGroup with error handling and concurrency control

go-waitgroup How to use An package that allows you to use the constructs of a sync.WaitGroup to create a pool of goroutines and control the concurrenc

Dec 31, 2022
A lib for monitoring runtime goroutine stack

Overview A lib for monitoring runtime goroutine stack. Such as wait for goroutines to exit, leak detection, etc. Features context.Context first design

Oct 31, 2022
Run functions in parallel :comet:

Parallel fn Run functions in parallel. Limit the number of goroutines running at the same time. Installation go get -u github.com/rafaeljesus/parallel

Sep 26, 2022
Simply way to control goroutines execution order based on dependencies
Simply way to control goroutines execution order based on dependencies

Goflow Goflow is a simply package to control goroutines execution order based on dependencies. It works similar to async.auto from node.js async packa

Dec 8, 2022
Provides some convenient API, includes Goid(), AllGoid(), and LocalStorage, which is a goroutine's local storage, just like ThreadLocal in other languages.

routine 中文版 routine encapsulates and provides some easy-to-use, high-performance goroutine context access interfaces, which can help you access corout

Dec 30, 2022
Worker - A Golang library that provides worker pools

Worker A Golang library that provides worker pools. Usage See *_test.go files. T

Apr 15, 2022
Reduce debugging time while programming Go. Use static and stack-trace analysis to determine which func call causes the error.
Reduce debugging time while programming Go. Use static and stack-trace analysis to determine which func call causes the error.

Errlog: reduce debugging time while programming Introduction Use errlog to improve error logging and speed up debugging while you create amazing code

Nov 18, 2022
Package iter provides generic, lazy iterators, functions for producing them from primitive types, as well as functions and methods for transforming and consuming them.

iter Package iter provides generic, lazy iterators, functions for producing them from primitive types, as well as functions and methods for transformi

Dec 16, 2022
Package gostackparse parses goroutines stack traces as produced by panic() or debug.Stack() at ~300 MiB/s.

gostackparse Package gostackparse parses goroutines stack traces as produced by panic() or debug.Stack() at ~300 MiB/s. Parsing this data can be usefu

Dec 1, 2022