redis

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventBridgeChannel = "blocky_sync_enabled"
)

Variables

This section is empty.

Functions

func New

func New(ctx context.Context, cfg *config.Redis) (*goredis.Client, error)

New creates a new Redis connection. Returns nil if Redis is not configured.

Types

type EventBusBridge added in v0.30.0

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

EventBusBridge connects the local event bus with Redis pub/sub for blocking state synchronization.

func NewEventBusBridge added in v0.30.0

func NewEventBusBridge(ctx context.Context, client *goredis.Client) (*EventBusBridge, error)

NewEventBusBridge creates a new EventBusBridge that synchronizes blocking state between local event bus and Redis pub/sub.

func (*EventBusBridge) Close added in v0.30.0

func (b *EventBusBridge) Close() error

Close stops the subscriber goroutine and unsubscribes from the local event bus. It is safe to call multiple times.

type PubSubLoop added in v0.30.0

type PubSubLoop struct {
	Client  *goredis.Client
	Channel string
	Logger  *logrus.Entry
	Handler func(ctx context.Context, payload string)
}

PubSubLoop manages a Redis pub/sub subscription with automatic reconnection. It calls handler for each received message payload and reconnects with exponential backoff when the channel closes unexpectedly.

func (*PubSubLoop) Run added in v0.30.0

func (p *PubSubLoop) Run(ctx context.Context)

Run subscribes to the channel and processes messages until ctx is cancelled. It reconnects automatically on unexpected channel closure.

func (*PubSubLoop) RunWithSub added in v0.30.0

func (p *PubSubLoop) RunWithSub(ctx context.Context, initial *goredis.PubSub)

RunWithSub is like Run but uses an existing subscription for the first iteration. If initial is nil, a new subscription is created.

Jump to

Keyboard shortcuts

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