bus

package
v0.0.0-...-a8698a8 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChannelBus

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

ChannelBus implements the MessageBus interface using Go channels

func NewChannelBus

func NewChannelBus() *ChannelBus

NewChannelBus creates a new ChannelBus

func (*ChannelBus) Close

func (b *ChannelBus) Close() error

Close shuts down the message bus

func (*ChannelBus) Publish

func (b *ChannelBus) Publish(ctx context.Context, topic string, event sse.Event) error

Publish sends a message to all subscribers of a topic

func (*ChannelBus) Subscribe

func (b *ChannelBus) Subscribe(ctx context.Context, topic string) (<-chan sse.Event, error)

Subscribe returns a channel that receives events for a specific topic

func (*ChannelBus) Unsubscribe

func (b *ChannelBus) Unsubscribe(ctx context.Context, topic string, ch <-chan sse.Event) error

Unsubscribe removes a subscription for a specific topic

type RedisBus

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

RedisBus implements the MessageBus interface using Redis PubSub.

func NewRedisBus

func NewRedisBus(client redis.UniversalClient) (*RedisBus, error)

NewRedisBus creates a new Redis SSE message bus. It accepts any redis.UniversalClient (e.g., *redis.Client, *redis.ClusterClient).

func NewRedisBusWithConfig

func NewRedisBusWithConfig(client redis.UniversalClient, bufferSize int) (*RedisBus, error)

NewRedisBusWithConfig creates a new Redis SSE message bus with custom buffer size.

func (*RedisBus) Close

func (r *RedisBus) Close() error

Close closes the Redis client connection and all subscriptions.

func (*RedisBus) Publish

func (r *RedisBus) Publish(ctx context.Context, topic string, event sse.Event) error

Publish sends a message to the specified topic. The message will be encoded as JSON before publishing.

func (*RedisBus) Subscribe

func (r *RedisBus) Subscribe(ctx context.Context, topic string) (<-chan sse.Event, error)

Subscribe returns a channel that receives events for a specific topic.

func (*RedisBus) Unsubscribe

func (r *RedisBus) Unsubscribe(ctx context.Context, topic string, ch <-chan sse.Event) error

Unsubscribe removes a subscription for a specific topic.

Jump to

Keyboard shortcuts

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