redissmq

package module
v0.0.0-...-151a5cc Latest Latest
Warning

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

Go to latest
Published: Aug 16, 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

📦 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

func NewConsumer

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

func NewProducer

func NewProducer() *producer.Producer

func Shutdown

func Shutdown()

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.
errs
Package errs provides shared sentinel errors for the internal layer.
Package errs provides shared sentinel errors for the internal layer.
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
namespace
Package namespace provides namespace-level operations for RedisSMQ.
Package namespace provides namespace-level operations for RedisSMQ.
queue/q
Package queue provides message queue operations including CRUD, rate limiting, and state management.
Package queue provides message queue operations including CRUD, rate limiting, and state management.

Jump to

Keyboard shortcuts

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