Skip to content
Mauricio Gomes edited this page Jan 3, 2026 · 4 revisions

Senna is a background job processing library for Go, backed by Redis or Valkey. It provides reliable job queuing, scheduling, retries, rate limiting, and batch processing with a clean, middleware-based architecture.

Supported Backends

  • Redis 6.2+
  • Valkey 7.2+

Both backends are fully supported and tested.

Key Features

Feature Description
Persistent Queues Jobs are stored in Redis/Valkey and survive restarts
Scheduled Jobs Run jobs at a specific time or after a delay
Automatic Retries Configurable exponential backoff with dead letter queue
Priority Queues Multiple queues with weighted priority distribution
Rate Limiting 5 distributed algorithms: bucket, sliding window, leaky bucket, concurrent, points
Batch Processing Group jobs and get callbacks on completion
Periodic Jobs Cron-based scheduling with distributed coordination
Encryption AES-GCM encryption for sensitive job arguments
Unique Jobs Prevent duplicate jobs with deduplication keys
Middleware Extensible middleware pattern for cross-cutting concerns
Graceful Shutdown Wait for in-flight jobs to complete

Installation

go get github.com/mgomes/senna

Quick Example

Enqueue a job:

c, _ := client.New(&client.Config{
    Redis:     senna.RedisConfig{Addr: "localhost:6379"},
    Namespace: "myapp",
})

c.Enqueue(ctx, "send_email", map[string]any{
    "to":      "user@example.com",
    "subject": "Welcome!",
})

Process jobs:

w, _ := worker.New(&worker.Config{
    Redis:     senna.RedisConfig{Addr: "localhost:6379"},
    Namespace: "myapp",
    Settings:  senna.WorkerSettings{Concurrency: 10},
})

w.Register("send_email", func(ctx context.Context, job *senna.Job) error {
    to := job.Args["to"].(string)
    // send email...
    return nil
})

w.Run(ctx)

Documentation

Clone this wiki locally