redissmq

package module
v0.0.0-...-25812f9 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 12 Imported by: 0

README

RedisSMQ

High‑performance Redis message queue for Go
simple to use, built for scale.

Go Reference


Other implementations: redis-smq (TypeScript)
Language‑agnostic concepts: redis-smq-docs – architecture, queues, exchanges, and more.

✨ Why RedisSMQ?

  • Full‑featured – FIFO, LIFO, priority queues, pub/sub, exchanges, scheduling, consumer groups, rate limiting.
  • Reliable – Acknowledgements, dead‑letter queues, retries, and message persistence.
  • Cross‑language – Messages published from Go can be consumed by Node.js (and vice versa).
  • Go‑native – Idiomatic API, context support, and clean concurrency.

📋 Requirements

  • Go ≥ 1.25
  • Redis ≥ 4

📊 See BUILD.md for CI status, code coverage, and build instructions.

📦 Installation

go get github.com/weyoss/go-redis-smq

🚀 Quick Start

1. Initialize

package main

import (
    "context"
    "log"
    "github.com/weyoss/go-redis-smq"
)

func main() {
    ctx := context.Background()
    if err := redissmq.Init(ctx, redissmq.Config{Addr: "127.0.0.1:6379"}); err != nil {
        log.Fatal(err)
    }
    defer redissmq.Shutdown()
}

2. Create a Queue

import (
    "github.com/weyoss/go-redis-smq/pkg/queue"
    "github.com/weyoss/go-redis-smq/pkg/queue/q"
)

params := q.MustQueueParams("orders")
if err := queue.Create(ctx, params, q.TypeFIFO, q.DeliveryPointToPoint); err != nil {
    log.Fatal(err)
}

3. Produce a Message

import (
    "github.com/weyoss/go-redis-smq/pkg/message/msg"
)

producer := redissmq.NewProducer()
producer.Run(ctx)
defer producer.Shutdown(ctx)

m := msg.New().SetBody([]byte("Hello World")).SetQueue(params)
ids, err := producer.Produce(ctx, m)
if err != nil {
    log.Fatal(err)
}
fmt.Printf("Produced: %v\n", ids)

4. Consume Messages

consumer := redissmq.NewConsumer()
consumer.Consume(params, func(ctx context.Context, m *msg.Transferable) error {
    fmt.Printf("Received: %v\n", string(m.Body))
    return nil // acknowledge
})
if err := consumer.Run(ctx); err != nil {
    log.Fatal(err)
}
defer consumer.Shutdown()

📚 API Overview

The Go library provides idiomatic, context‑aware APIs for:

  • SystemInit, Shutdown
  • QueuesCreate, Pause, Resume, Stop, SetRateLimit, BrowseMessages, ListAll
  • MessagesGet, Delete, Requeue
  • ProducersRun, Produce (direct or via exchanges)
  • ConsumersConsume, ConsumeWithGroup, Run, Shutdown
  • Exchanges – Direct, Topic, Fanout with bindings
  • NamespacesList, Delete, ListQueues, ListExchanges
  • Configuration – Runtime config management

See the full Go documentation for details.

🔗 Interoperability

Because the Go and TypeScript implementations share the same protocol, you can:

  • Produce in Go, consume in Node.js (and vice versa).
  • Manage queues and exchanges from either language.
  • Use the same Redis instance for both stacks.

The REST API and Web UI (from the TypeScript repo) work seamlessly with Go‑created queues.

🛠️ Administration & Monitoring

The RedisSMQ REST API and Web UI (from the TypeScript implementation) are fully compatible with queues created by this Go client.

🧩 Compatibility

Always match your library version with the correct language‑agnostic specification.
Check the version compatibility matrix before upgrading.

📄 License

MIT – see LICENSE.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(ctx context.Context, cfg Config) error

Init initialises RedisSMQ

func NewConsumer

func NewConsumer(opts ...c.Option) *consumer.Consumer

NewConsumer creates a new consumer and registers it for lifecycle management.

func NewProducer

func NewProducer() *producer.Producer

NewProducer creates a new producer and registers it for lifecycle management.

func Shutdown

func Shutdown()

Shutdown gracefully stops RedisSMQ.

It stops the purge worker, consumers, producers, event buses, logger, configuration, and Redis client. Shutdown is safe to call multiple times and supports being called again after a new Init.

Types

type Config

type Config = redis.Config

Config is the Redis connection configuration.

Directories

Path Synopsis
examples
batch command
Example: Batch acknowledgments for high throughput.
Example: Batch acknowledgments for high throughput.
browsing command
Example: Browse queue messages by category.
Example: Browse queue messages by category.
consumer command
Example: Consume messages from a queue.
Example: Consume messages from a queue.
direct_exchange command
Example: Exchange-based routing.
Example: Exchange-based routing.
fanout_exchange command
Example: Fanout exchange — broadcast to all bound queues.
Example: Fanout exchange — broadcast to all bound queues.
producer command
Example: Produce messages to a queue.
Example: Produce messages to a queue.
producer_consumer command
Example: Full producer and consumer in one process.
Example: Full producer and consumer in one process.
pubsub command
Example: Pub/Sub with consumer groups.
Example: Pub/Sub with consumer groups.
scheduling command
Example: Scheduled and delayed messages.
Example: Scheduled and delayed messages.
topic_exchange command
Example: Topic exchange with pattern-based routing.
Example: Topic exchange with pattern-based routing.
internal
codec
Package codec provides interfaces and implementations for serializing domain types to and from Redis storage formats.
Package codec provides interfaces and implementations for serializing domain types to and from Redis storage formats.
config/events
Package events defines internal configuration event names and payload types.
Package events defines internal configuration event names and payload types.
consumer/events
Package events defines internal consumer event names and payload types.
Package events defines internal consumer event names and payload types.
errs
Package errs provides shared sentinel errors for the internal layer.
Package errs provides shared sentinel errors for the internal layer.
producer/events
Package events defines internal producer event names and payload types.
Package events defines internal producer event names and payload types.
queue/events
Package events defines internal queue event names and payload types.
Package events defines internal queue event names and payload types.
redis
Package redis provides the Redis client singleton and shared utilities for hash, set, and transaction operations.
Package redis provides the Redis client singleton and shared utilities for hash, set, and transaction operations.
util/cron
go/internal/util/cron/cron.go
go/internal/util/cron/cron.go
util/logger/cfg
Package cfg wires the application configuration into the logger's ConfigProvider.
Package cfg wires the application configuration into the logger's ConfigProvider.
pkg
config
Package config provides public APIs for reading, saving, reloading, and resetting RedisSMQ system configuration.
Package config provides public APIs for reading, saving, reloading, and resetting RedisSMQ system configuration.
config/cfg
Package cfg defines the public configuration structures used by RedisSMQ.
Package cfg defines the public configuration structures used by RedisSMQ.
consumer
Package consumer provides the public API for creating and managing RedisSMQ consumers.
Package consumer provides the public API for creating and managing RedisSMQ consumers.
consumer/c
Package c provides configuration options and types for RedisSMQ consumers.
Package c provides configuration options and types for RedisSMQ consumers.
consumer/events
Package events provides public subscription functions for RedisSMQ consumer events.
Package events provides public subscription functions for RedisSMQ consumer events.
message
Package message provides a public API for managing RedisSMQ messages.
Package message provides a public API for managing RedisSMQ messages.
message/msg
Package msg defines message types, statuses, priorities, and related configuration used by the public message API.
Package msg defines message types, statuses, priorities, and related configuration used by the public message API.
namespace
Package namespace provides namespace-level operations for RedisSMQ.
Package namespace provides namespace-level operations for RedisSMQ.
namespace/ns
Package ns defines namespace-specific sentinel errors and validation errors used by the public namespace API.
Package ns defines namespace-specific sentinel errors and validation errors used by the public namespace API.
producer
Package producer provides the public API for creating and managing RedisSMQ producers.
Package producer provides the public API for creating and managing RedisSMQ producers.
producer/events
Package events provides public subscription functions for RedisSMQ producer events.
Package events provides public subscription functions for RedisSMQ producer events.
producer/p
Package p provides sentinel errors returned by the RedisSMQ producer.
Package p provides sentinel errors returned by the RedisSMQ producer.
queue
Package queue provides a high-level, user-facing API for managing RedisSMQ queues.
Package queue provides a high-level, user-facing API for managing RedisSMQ queues.
queue/events
Package events provides public subscription functions for RedisSMQ queue events.
Package events provides public subscription functions for RedisSMQ queue events.

Jump to

Keyboard shortcuts

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