modulepackage
4.0.0-beta.4
Repository: https://github.com/vmihailenco/taskq.git
Documentation: pkg.go.dev
# README
Golang asynchronous task/job queue with Redis, SQS, IronMQ, and in-memory backends
taskq is brought to you by :star: uptrace/uptrace. Uptrace is an open source and blazingly fast distributed tracing tool powered by OpenTelemetry and ClickHouse. Give it a star as well!
Features
- Redis, SQS, IronMQ, and in-memory backends.
- Automatically scaling number of goroutines used to fetch (fetcher) and process messages (worker).
- Global rate limiting.
- Global limit of workers.
- Call once - deduplicating messages with same name.
- Automatic retries with exponential backoffs.
- Automatic pausing when all messages in queue fail.
- Fallback handler for processing failed messages.
- Message batching. It is used in SQS and IronMQ backends to add/delete messages in batches.
- Automatic message compression using snappy / s2.
Resources:
Getting started
To get started, see Golang Task Queue documentation.
Producer:
import (
"github.com/vmihailenco/taskq/v3"
"github.com/vmihailenco/taskq/v3/redisq"
)
// Create a queue factory.
var QueueFactory = redisq.NewFactory()
// Create a queue.
var MainQueue = QueueFactory.RegisterQueue(&taskq.QueueOptions{
Name: "api-worker",
Redis: Redis, // go-redis client
})
// Register a task.
var CountTask = taskq.RegisterTask("counter", &taskq.TaskOptions{
Handler: func() error {
IncrLocalCounter()
return nil
},
})
ctx := context.Background()
// And start producing.
for {
// Call the task without any args.
err := MainQueue.AddJob(ctx, CountTask.NewJob())
if err != nil {
panic(err)
}
time.Sleep(time.Second)
}
Consumer:
// Start consuming the queue.
if err := MainQueue.Start(context.Background()); err != nil {
log.Fatal(err)
}
See also
- Golang ORM for PostgreSQL, MySQL, MSSQL, and SQLite
- Golang PostgreSQL
- Golang HTTP router
- Golang ClickHouse
Contributors
Thanks to all the people who already contributed!
# Packages
No description provided by the author
# Functions
NewConsumer creates new Consumer for the queue using provided processing options.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
SetLogger configures the logger used internally to opentelemetry.
No description provided by the author
StartConsumer creates new QueueConsumer and starts it.
Version is the current release version.
# Variables
No description provided by the author
ErrDuplicate is returned when adding duplicate message to the queue.
No description provided by the author
# Structs
Consumer reserves messages from the queue, processes them, and then either releases or deletes messages from the queue.
No description provided by the author
Job is used to create and retrieve messages from a queue.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Interfaces
No description provided by the author
No description provided by the author
Factory is an interface that abstracts creation of new queues.
Handler is an interface for processing messages.
No description provided by the author
QueueConsumer reserves messages from the queue, processes them, and then either releases or deletes messages from the queue.
No description provided by the author
No description provided by the author
# Type aliases
No description provided by the author