Project

senna

0.0
No release in over 3 years
High performance, background jobs for Ruby.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

= 3.8.0

Runtime

~> 1.20
~> 1.24
>= 4.0.2
 Project Readme

Senna

Senna

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+

Features

  • Persistent job queues backed by Redis or Valkey
  • Scheduled jobs (run at a specific time or after a delay)
  • Automatic retries with configurable backoff
  • Multiple queues with weighted or strict priority
  • Sequential queues for ordered, one-at-a-time processing
  • Distributed rate limiting (bucket, sliding window, leaky bucket, concurrent, points-based)
  • Job batching with completion callbacks
  • Iterable jobs for resumable large dataset processing
  • Job argument encryption (AES-GCM)
  • Unique jobs to prevent duplicates
  • Graceful shutdown with in-flight job completion
  • Middleware support for cross-cutting concerns
  • Per-job concurrency limits

Installation

go get github.com/mgomes/senna

Quick Start

Enqueuing Jobs

c, err := client.New(&client.Config{
    Redis:     senna.RedisConfig{Addr: "localhost:6379"},
    Namespace: "myapp",
})
if err != nil {
    log.Fatal(err)
}
defer c.Close()

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

// Enqueue with delay
c.EnqueueIn(ctx, 5*time.Minute, "send_reminder", map[string]any{"user_id": 123})

// Enqueue to specific queue
c.Enqueue(ctx, "process_payment", args, client.WithQueue("critical"))

Processing Jobs

w, err := worker.New(&worker.Config{
    Redis:     senna.RedisConfig{Addr: "localhost:6379"},
    Namespace: "myapp",
    Settings: senna.WorkerSettings{
        Concurrency: 10,
        Queues: []senna.QueueConfig{
            {Name: "critical", Priority: 10},
            {Name: "default", Priority: 5},
        },
    },
})
if err != nil {
    log.Fatal(err)
}

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

w.Run(ctx) // Blocks until shutdown signal

Documentation

For detailed documentation, see the Wiki:

License

MIT License. See LICENSE file for details.