Skip to content

Repository that implements goroutines abstractions with async / await structures

License

Notifications You must be signed in to change notification settings

F-Amaral/go-async

Repository files navigation

CI Lint Codecov

go-async

Repository that implements goroutines abstractions, making easy to run async code in Go.

Installation

go get github.com/f-amaral/go-async 

Features

Worker Pool

Creates a pool with a fixed number of workers that will execute the tasks sent to the pool.

package main

import (
	"encoding/json"
	"fmt"
	"github.com/f-amaral/go-async/pool"
)

func main() {
	inputSet := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}

	exFunc := func(i int) (int, error) {
		return i * 2, nil
	}

	p := pool.NewPool(10, exFunc)
	defer p.Close()

	result := p.Process(inputSet)
	resultBytes, _ := json.Marshal(result)
	fmt.Println(string(resultBytes))
	// Error Handling:
	fmt.Println(result.GetErrors()) 
	
}

About

Repository that implements goroutines abstractions with async / await structures

Resources

License

Stars

Watchers

Forks

Packages

No packages published