Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fredmaggiowski/gowq
A simple and straightforward workqueue manager in Go
https://github.com/fredmaggiowski/gowq
concurrent-programming threadpool workqueue
Last synced: 27 days ago
JSON representation
A simple and straightforward workqueue manager in Go
- Host: GitHub
- URL: https://github.com/fredmaggiowski/gowq
- Owner: fredmaggiowski
- License: mit
- Created: 2021-02-21T19:38:00.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-07-26T14:34:16.000Z (3 months ago)
- Last Synced: 2024-07-26T15:49:02.076Z (3 months ago)
- Topics: concurrent-programming, threadpool, workqueue
- Language: Go
- Homepage:
- Size: 29.3 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# goWQ
[![Build][build-svg]][build-link]
[![Go Report Card][report-card-svg]][report-card-link]A simple work queue manager to schedule jobs and then execute them on a defined pool of goroutines.
It can be used in two modes:
- *static*: allows to create a job queue and then run it waiting for all jobs to complete;
- *dynamic*: allows to run a job scheduler and then enqueue new jobs while the scheduler runs.## Examples
### Static Queue Usage
```go
wq := New[MyResult](2)wq.Push(func(ctx context.Context) (MyResult, error) {
// do something...
return MyResult{}, nil
})
results, errors := wq.RunAll(context.TODO())
```### Dynamic Queue Manager
```go
wq := New[MyResult](2)go func(ctx context.Context) {
wq.Start(ctx)
}(context.TODO())wq.Schedule(func(ctx context.Context) (MyResult, error) {
// do something...
return nil
})// Wait until all jobs have been completed.
_ := wq.Shutdown()
```[build-svg]: https://github.com/fredmaggiowski/gowq/actions/workflows/go.yml/badge.svg
[build-link]: https://github.com/fredmaggiowski/gowq/actions/workflows/go.yml
[report-card-svg]: https://goreportcard.com/badge/github.com/fredmaggiowski/gowq
[report-card-link]: https://goreportcard.com/report/github.com/fredmaggiowski/gowq