Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type MemoryPubSub ¶ added in v1.34.3
type MemoryPubSub struct {
// contains filtered or unexported fields
}
func NewMemory ¶
func NewMemory(opts ...Option) *MemoryPubSub
func (*MemoryPubSub) Close ¶ added in v1.34.3
func (m *MemoryPubSub) Close() error
func (*MemoryPubSub) Publish ¶ added in v1.34.3
Publish sends a message to all subscribers of the given topic. This method blocks until all subscribers have received the message or until ctx is cancelled or the pubsub instance is closed.
func (*MemoryPubSub) Subscribe ¶ added in v1.34.3
func (m *MemoryPubSub) Subscribe(ctx context.Context, topic string) (*Subscription, error)
type PubSub ¶
type PubSub interface {
Publisher
Subscriber
// Close closes the pubsub instance and releases all resources.
Close() error
}
type RedisConfig ¶
type RedisConfig struct {
// Client is the Redis client to use.
// If nil, a client is created from the URL.
// If both Client and URL are provided, Client takes precedence.
Client *redis.Client
// URL is the Redis URL to use.
// If empty, the Redis client is not created.
URL string
// Prefix is the prefix to use for all topics.
Prefix string
}
RedisConfig configures the Redis pubsub backend.
type RedisPubSub ¶ added in v1.34.3
type RedisPubSub struct {
// contains filtered or unexported fields
}
func NewRedis ¶
func NewRedis(config RedisConfig, opts ...Option) (*RedisPubSub, error)
func (*RedisPubSub) Close ¶ added in v1.34.3
func (r *RedisPubSub) Close() error
func (*RedisPubSub) Subscribe ¶ added in v1.34.3
func (r *RedisPubSub) Subscribe(ctx context.Context, topic string) (*Subscription, error)
type Subscriber ¶
type Subscriber interface {
// Subscribe subscribes to a topic and returns a channel for receiving messages.
// The channel will be closed when the context is cancelled.
Subscribe(ctx context.Context, topic string) (*Subscription, error)
}
type Subscription ¶
type Subscription struct {
// contains filtered or unexported fields
}
func (*Subscription) Close ¶
func (s *Subscription) Close()
func (*Subscription) Receive ¶
func (s *Subscription) Receive() <-chan Message
Click to show internal directories.
Click to hide internal directories.