Documentation ¶
Overview ¶
Package bnsq provides a type-safe NSQ pubsub client.
Index ¶
Constants ¶
const (
EventsubNotifyTopic = "eventsub.notify"
)
const (
IncomingWebsocketMessageTopic = "eventsub.incoming"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventsubNotify ¶
type EventsubNotify struct{}
EventsubNotify is an EventsubNotify message as sent over NSQ.
type EventsubNotifyPublisher ¶
type EventsubNotifyPublisher struct {
// contains filtered or unexported fields
}
EventsubNotifyPublisher publishes EventsubNotify messages to NSQ.
func NewEventsubNotifyPublisher ¶
func NewEventsubNotifyPublisher(addr string, opts ...PublisherOption) *EventsubNotifyPublisher
NewEventsubNotifyPublisher creates a new EventsubNotifyPublisher that will connect to the specified address.
func (*EventsubNotifyPublisher) NotifyEventsubUpdates ¶
func (p *EventsubNotifyPublisher) NotifyEventsubUpdates(ctx context.Context) error
Publish publishes an EventsubNotify message, returning when the message has finished publishing or the context is canceled.
type EventsubNotifySubscriber ¶
type EventsubNotifySubscriber struct { Addr string Channel string Opts []SubscriberOption OnEventsubNotify func(i *EventsubNotify, metadata *Metadata) error }
EventsubNotifySubscriber subscribes to EventsubNotify messages, executing OnEventsubNotify for each message.
type IncomingWebsocketMessage ¶
type IncomingWebsocketMessage struct {
Message *eventsub.WebsocketMessage `json:"message"`
}
IncomingWebsocketMessage is an IncomingWebsocketMessage message as sent over NSQ.
type IncomingWebsocketMessagePublisher ¶
type IncomingWebsocketMessagePublisher struct {
// contains filtered or unexported fields
}
IncomingWebsocketMessagePublisher publishes IncomingWebsocketMessage messages to NSQ.
func NewIncomingWebsocketMessagePublisher ¶
func NewIncomingWebsocketMessagePublisher(addr string, opts ...PublisherOption) *IncomingWebsocketMessagePublisher
NewIncomingWebsocketMessagePublisher creates a new IncomingWebsocketMessagePublisher that will connect to the specified address.
func (*IncomingWebsocketMessagePublisher) Publish ¶
func (p *IncomingWebsocketMessagePublisher) Publish(ctx context.Context, m *eventsub.WebsocketMessage) error
Publish publishes an IncomingWebsocketMessage message, returning when the message has finished publishing or the context is canceled.
type IncomingWebsocketMessageSubscriber ¶
type IncomingWebsocketMessageSubscriber struct { Addr string Channel string Opts []SubscriberOption OnIncomingWebsocketMessage func(i *IncomingWebsocketMessage, metadata *Metadata) error }
IncomingWebsocketMessageSubscriber subscribes to IncomingWebsocketMessage messages, executing OnIncomingWebsocketMessage 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 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 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.