redis

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2026 License: MIT Imports: 5 Imported by: 0

README

BabelQueue Redis transport (Go)

Go Reference

A Redis-backed babelqueue.Transport for the BabelQueue Go runtime, using the reliable-queue pattern (RPUSH to produce, BLMOVE head → per-queue processing list to reserve, LREM to ack). Built on go-redis.

go get github.com/babelqueue/babelqueue-go/redis
import (
    babelqueue "github.com/babelqueue/babelqueue-go"
    "github.com/babelqueue/babelqueue-go/redis"
)

tr, err := redis.New("redis://localhost:6379/0")
if err != nil { panic(err) }
defer tr.Close()

app := babelqueue.NewApp(tr, babelqueue.WithDefaultQueue("orders"))
app.Handle("urn:babel:orders:created", func(ctx context.Context, env babelqueue.Envelope) error {
    // handle env.Data ...
    return nil
})
app.Publish(ctx, "urn:babel:orders:created", map[string]any{"order_id": 1042})
app.Consume(ctx)

Bring your own client with redis.NewWithClient(client) (custom pool / TLS / auth). The BabelQueue core stays zero-dependency; this module is the only place go-redis is pulled in.

Full spec: babelqueue.com · MIT © Muhammet Şafak

Documentation

Overview

Package redis is a Redis-backed babelqueue.Transport for the BabelQueue Go runtime. It uses the reliable-queue pattern: RPUSH to produce, BLMOVE the head to a per-queue processing list to reserve (so an in-flight message survives a worker crash), and LREM from that list to acknowledge.

tr, _ := redis.New("redis://localhost:6379/0")
app := babelqueue.NewApp(tr, babelqueue.WithDefaultQueue("orders"))

This is a Go-owned reliable queue; full parity with Laravel's reserved-set reservation on a *shared* Redis queue is a separate task.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Transport)

Option customizes New / NewWithClient.

func WithProcessingSuffix

func WithProcessingSuffix(suffix string) Option

WithProcessingSuffix overrides the per-queue processing-list suffix (default ":processing").

type Transport

type Transport struct {
	// contains filtered or unexported fields
}

Transport implements babelqueue.Transport over Redis.

func New

func New(url string, opts ...Option) (*Transport, error)

New connects to Redis from a redis:// or rediss:// URL.

func NewWithClient

func NewWithClient(client *goredis.Client, opts ...Option) *Transport

NewWithClient wraps an existing go-redis client (bring your own pool/TLS/auth).

func (*Transport) Ack

Ack removes the reserved message from its processing list (LREM).

func (*Transport) Close

func (t *Transport) Close() error

Close releases the underlying client.

func (*Transport) Pop

func (t *Transport) Pop(ctx context.Context, queue string, timeout time.Duration) (*babelqueue.ReceivedMessage, error)

Pop atomically moves the head of queue to its processing list and returns it, blocking up to timeout. It returns (nil, nil) when no message arrives in time.

func (*Transport) Publish

func (t *Transport) Publish(ctx context.Context, queue, body string) error

Publish appends body to queue (RPUSH).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL