BWorker is a lightweight and easy-to-use Go library that provides a simple and efficient way to execute concurrent tasks.
It is designed to be flexible enough to handle a wide range of use cases, from simple tasks such as initializing app resources to more complex tasks such as processing large use-cases.
To install BWorker, you can run the following command:
go get github.com/bearaujus/bworker
1. Pool Worker
An BWorker instance with specified concurrency level. Features:
- WithJobPoolSize: Set the size of the job pool size.
- WithWorkerStartupDelay: Set the delay interval between the startup of each worker in the worker pool.
- WithRetry: Set the number of times to retry a failed job.
- WithError: Set a pointer to an error variable that will be populated if any job fails.
- WithErrors: Set a pointer to a slice of error variables that will be populated if any job fails.
2. Flex Worker
An BWorker instance with unlimited concurrency level. Features:
- WithRetry: Set the number of times to retry a failed job.
- WithError: Set a pointer to an error variable that will be populated if any job fails.
- WithErrors: Set a pointer to a slice of error variables that will be populated if any job fails.
- Add
PoolWorker
documentation & example - Add
FlexWorker
documentation & example - Add internal test cases
- Support backoff retry
- Support fixed delay retry
- Function
Do
andDoSimple
atPoolWorker
sometimes will block the thread, so we need to handle this by addingDoWithContext
&DoSimpleWithContext
This project is licensed under the MIT License - see the LICENSE file for details.