https://github.com/symonk/tasq
[alpha] Highly performant concurrent task queue in go :star2:
https://github.com/symonk/tasq
golang
Last synced: about 2 months ago
JSON representation
[alpha] Highly performant concurrent task queue in go :star2:
- Host: GitHub
- URL: https://github.com/symonk/tasq
- Owner: symonk
- License: apache-2.0
- Created: 2024-11-10T17:41:36.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-11-27T22:07:11.000Z (6 months ago)
- Last Synced: 2024-12-21T20:43:53.287Z (5 months ago)
- Language: Go
- Size: 101 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://pkg.go.dev/github.com/symonk/tasq)
[](https://github.com/symonk/tasq/actions/workflows/test.yml)
[](https://codecov.io/gh/symonk/tasq)
[](https://goreportcard.com/report/github.com/symonk/tasq)
[](https://github.com/symonk/tasq/blob/master/LICENSE)> [!CAUTION]
> tasq is currently in alpha and not fit for production level use.# Tasq (_Task Queue_)
`tasq` is a high performance worker pool for distributing tasks across a collection of worker
goroutines. `tasq` is dynamic in nature and auto scales depending on the number of work available
at any point in time.If you have a bunch of tasks to do and want an easy way to distribute them in a parallel manner without
the hassle of managing worker dispatching yourself `tasq` is for you.`tasq` has built in support for pausing the pool for a given time (configurable via a `context`) for improved
error handling scenarios where upstream dependencies may be non functional.> [!NOTE]
> By design `tasq` does not propagate errors or return values, tasks should handle their own persistence
> by (for example) shovelling their return values into a channel etc.`tasq` follows semantic versioning.
-----
### Quickstart:
```go
package mainimport (
"github.com/symonk/tasq""time"
)func main() {
pool := tasq.New(tasq.WithMaxWorkers(10))
results := make(chan string)
for i := range 100 {
pool.Enqueue(func() {
time.Sleep(time.Second)
results <- fmt.Sprintf("%d", i)
})
}
close(results)
go func() {
for r := range results {
fmt.Println(r)
}
}()
pool.Stop()
}
```