Documentation
¶
Index ¶
Constants ¶
const (
EventBridgeChannel = "blocky_sync_enabled"
)
Variables ¶
This section is empty.
Functions ¶
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
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.