Documentation
¶
Index ¶
- type Config
- type Option
- type OptionFunc
- type PubSub
- func (r *PubSub) Close(_ context.Context) error
- func (ps *PubSub) Publish(ctx context.Context, topic string, payload []byte, ...) error
- func (ps *PubSub) Subscribe(ctx context.Context, topic string, handler func(msg *pubsub.Msg) error, ...) pubsub.Consumer
- func (ps *PubSub) SubscribeChan(ctx context.Context, topic string, options ...pubsub.SubscribeOption) (pubsub.Consumer, <-chan *pubsub.Msg)
- type RedisPubSub
- type SubscribeConfig
- type SubscribeOption
- type SubscribeOptionFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option interface {
Apply(*Config)
}
An Option configures a pubsub instance.
func WithHealthCheckInterval ¶
WithHealthCheckInterval specifies the config health check interval. PubSub will ping Server if it does not receive any messages within the interval (redis, ...). To disable health check, use zero interval.
func WithNamespace ¶
WithNamespace returns an option that set config namespace.
func WithSendTimeout ¶
WithSendTimeout specifies the pubsub send timeout after which the message is dropped.
type OptionFunc ¶
type OptionFunc func(*Config)
OptionFunc is a function that configures a pubsub config.
type PubSub ¶
type PubSub struct {
// contains filtered or unexported fields
}
func (*PubSub) Publish ¶
func (ps *PubSub) Publish(ctx context.Context, topic string, payload []byte, opts ...pubsub.PublishOption) error
Publish event topic to message broker with payload.
type RedisPubSub ¶
type RedisPubSub interface { }
type SubscribeConfig ¶
type SubscribeConfig struct {
// contains filtered or unexported fields
}
type SubscribeOption ¶
type SubscribeOption interface {
Apply(*SubscribeConfig)
}
SubscribeOption configures a subscription config.
func WithChannelHealthCheckInterval ¶
func WithChannelHealthCheckInterval(value time.Duration) SubscribeOption
WithChannelHealthCheckInterval specifies the channel health check interval. PubSub will ping Server if it does not receive any messages within the interval. To disable health check, use zero interval.
func WithChannelNamespace ¶
func WithChannelNamespace(value string) SubscribeOption
WithNamespace returns an channel option that configures namespace.
func WithChannelSendTimeout ¶
func WithChannelSendTimeout(value time.Duration) SubscribeOption
WithChannelSendTimeout specifies the channel send timeout after which the message is dropped.
func WithChannelSize ¶
func WithChannelSize(value int) SubscribeOption
WithChannelSize specifies the Go chan size that is used to buffer incoming messages for subscriber.
func WithTopics ¶
func WithTopics(topics ...string) SubscribeOption
WithTopics specifies the topics to subsribe.
type SubscribeOptionFunc ¶
type SubscribeOptionFunc func(*SubscribeConfig)
SubscribeOptionFunc is a function that configures a subscription config.
func (SubscribeOptionFunc) Apply ¶
func (f SubscribeOptionFunc) Apply(config *SubscribeConfig)
Apply calls f(subscribeConfig).