tunny — screenshot of github.com

tunny

Tunny is a Golang library for spawning and managing a goroutine pool, offering a synchronous API to limit work. I find it useful for controlling concurrency in CPU-heavy scenarios.

Visit github.com →

Questions & Answers

What is Tunny?
Tunny is a Go library designed to spawn and manage a fixed-size pool of goroutines. It provides a synchronous API for submitting work and limiting the number of concurrent operations.
Who should use Tunny?
Tunny is for Go developers who need to manage and limit the parallel processing capacity for tasks coming from various asynchronous sources. It is particularly useful for CPU-heavy jobs, such as those originating from HTTP requests.
When is Tunny a good choice for goroutine management?
It is a good choice when you have an arbitrary number of asynchronous tasks that require processing but need to cap the number of concurrent executions to match available resources like CPU cores. This helps prevent resource exhaustion.
Does Tunny support job timeouts?
Yes, Tunny supports job timeouts through its ProcessTimed method, which accepts a time.Duration, or by using ProcessCtx with a context.Context to handle deadlines. This allows for graceful handling of long-running tasks.
Can the size of a Tunny goroutine pool be changed dynamically?
Yes, the size of a Tunny pool can be adjusted at any time using the SetSize(int) method. This operation is safe to perform from any goroutine, even while others are processing jobs.