Documentation ¶
Overview ¶
Package bnsq provides a type-safe NSQ pubsub client.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChannelUpdatesNotification ¶
type ChannelUpdatesNotification struct {
BotName string `json:"bot_name"`
}
ChannelUpdatesNotification is a notification that the IRC service should update its channel list and potentially join/part any changed channels.
type IncomingPublisher ¶
type IncomingPublisher struct {
// contains filtered or unexported fields
}
IncomingPublisher publishes incoming messages to NSQ.
func NewIncomingPublisher ¶
func NewIncomingPublisher(addr string, opts ...PublisherOption) *IncomingPublisher
NewIncomingPublisher creates a new IncomingPublisher that will connect to the specified address.
type IncomingSubscriber ¶
type IncomingSubscriber struct { Addr string Channel string Opts []SubscriberOption OnIncoming func(i *Incoming, metadata *Metadata) error }
IncomingSubscriber subscribes to incoming messages, executing OnIncoming for each message.
type Metadata ¶
type Metadata struct { Timestamp time.Time `json:"timestamp"` TraceSpan []byte `json:"trace_span"` Correlation xid.ID `json:"xid"` }
Metadata contains metadata that will be sent with every NSQ message.
func (*Metadata) ParentSpan ¶
func (m *Metadata) ParentSpan() trace.SpanContext
ParentSpan returns the span that sent the message.
type NotifyPublisher ¶
type NotifyPublisher struct {
// contains filtered or unexported fields
}
NotifyPublisher publishes notifications to NSQ.
func NewNotifyPublisher ¶
func NewNotifyPublisher(addr string, opts ...PublisherOption) *NotifyPublisher
NewNotifyPublisher creates a new NotifyPublisher that will connect to the specified address.
func (*NotifyPublisher) NotifyChannelUpdates ¶
func (p *NotifyPublisher) NotifyChannelUpdates(ctx context.Context, botName string) error
NotifyChannelUpdates publishes a channel update notification, returning when the notification has finished publishing or the context is canceled.
type NotifySubscriber ¶
type NotifySubscriber struct { Addr string BotName string Channel string Opts []SubscriberOption OnNotifyChannelUpdates func(n *ChannelUpdatesNotification, metadata *Metadata) error }
NotifySubscriber subscribes to notifications, executing a callback for each incoming notification.
type Option ¶
type Option interface { PublisherOption SubscriberOption }
Option is an option for both a publisher and a subscriber.
func WithConfig ¶
func WithConfig(config *nsq.Config) Option
WithConfig sets the NSQ config used for a NSQ connection. If not set or nil, the default NSQ configuration will be nil.
type PublisherOption ¶
type PublisherOption interface {
// contains filtered or unexported methods
}
PublisherOption is an option for a publisher.
type SendMessage ¶
type SendMessage struct { Origin string `json:"origin"` Target string `json:"target"` Message string `json:"message"` }
SendMessage is an outgoing message as sent over NSQ.
type SendMessagePublisher ¶
type SendMessagePublisher struct {
// contains filtered or unexported fields
}
SendMessagePublisher publishes outgoing messages to NSQ.
func NewSendMessagePublisher ¶
func NewSendMessagePublisher(addr string, opts ...PublisherOption) *SendMessagePublisher
NewSendMessagePublisher creates a new SendMessagePublisher that will connect to the specified address.
func (*SendMessagePublisher) Run ¶
func (p *SendMessagePublisher) Run(ctx context.Context) error
Run runs the publisher until the context is canceled.
func (*SendMessagePublisher) SendMessage ¶
func (p *SendMessagePublisher) SendMessage(ctx context.Context, origin, target, message string) error
SendMessage publishes a outgoing message, returning when the message has finished publishing or the context is canceled.
type SendMessageSubscriber ¶
type SendMessageSubscriber struct { Addr string Origin string Channel string Opts []SubscriberOption OnSendMessage func(sm *SendMessage, metadata *Metadata) error }
SendMessageSubscriber subscribes to outgoing message, executing OnSendMessage for each.
type SubscriberOption ¶
type SubscriberOption interface {
// contains filtered or unexported methods
}
SubscriberOption is an option for a subscriber.
func WithMaxAge ¶
func WithMaxAge(d time.Duration) SubscriberOption
WithMaxAge sets the maximum age that a subscriber will accept. If a message is too old, it will be dropped.