redis

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package redis provides a Redis implementation of the bus.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bus

type Bus[T any] struct {
	// contains filtered or unexported fields
}

Bus is a Redis-backed implementation of the Bus interface.

func New

func New[T any](redisConfig *bus.RedisBus) *Bus[T]

New creates a new RedisBus.

func NewWithClient

func NewWithClient[T any](client *redis.Client) *Bus[T]

NewWithClient creates a new RedisBus with an existing Redis client.

func (*Bus[T]) Close

func (b *Bus[T]) Close() error

Close closes the Redis client and all pubsub connections.

func (*Bus[T]) Publish

func (b *Bus[T]) Publish(ctx context.Context, topic string, msg T) error

Publish publishes a message to a Redis channel.

func (*Bus[T]) Subscribe

func (b *Bus[T]) Subscribe(ctx context.Context, topic string, handler func(T)) (unsubscribe func())

Subscribe subscribes to a Redis channel.

func (*Bus[T]) SubscribeOnce

func (b *Bus[T]) SubscribeOnce(ctx context.Context, topic string, handler func(T)) (unsubscribe func())

SubscribeOnce subscribes to a topic for a single message.

Jump to

Keyboard shortcuts

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