Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrPubSubClosed = errors.New("pubsub is closed") ErrInvalidTopic = errors.New("invalid topic name") )
Functions ¶
func NewRedis ¶
func NewRedis(config RedisConfig, opts ...Option) (*redisPubSub, error)
Types ¶
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 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.