Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NATSBackend ¶
type NATSBackend struct {
// contains filtered or unexported fields
}
NATSBackend publishes accepted notifications to JetStream.
func NewNATSBackend ¶
func NewNATSBackend(conf NATSConfig, log zerolog.Logger) (*NATSBackend, error)
NewNATSBackend connects to NATS and ensures the notification stream exists.
type NATSConfig ¶
type NATSConfig struct {
Address string `mapstructure:"address"`
Token string `mapstructure:"token"`
Stream string `mapstructure:"stream"`
Subject string `mapstructure:"subject"`
Durable string `mapstructure:"durable"`
Queue string `mapstructure:"queue"`
// Namespace scopes the stream, subject, durable and queue names so
// environments sharing one NATS server (for example QA, test and dev on the
// same host) each get their own isolated stream and queue group instead of
// consuming each other's events. Publisher and consumer must set the same
// value. Ignored for any name given explicitly above.
Namespace string `mapstructure:"namespace"`
}
NATSConfig configures the NATS notification backend and listener.
type NATSListener ¶
type NATSListener struct {
// contains filtered or unexported fields
}
NATSListener consumes notification envelopes from JetStream.
func NewNATSListener ¶
func NewNATSListener(conf NATSConfig, log zerolog.Logger) (*NATSListener, error)
NewNATSListener connects to NATS and ensures the notification stream exists.
func (*NATSListener) Close ¶
func (l *NATSListener) Close() error
Close drains the NATS listener connection.
func (*NATSListener) Queue ¶
func (l *NATSListener) Queue() string
Queue returns the queue group the listener joins.
func (*NATSListener) Start ¶
func (l *NATSListener) Start(ctx context.Context, handler func(context.Context, model.Envelope) error) error
Start subscribes to the notification stream. Messages are acked only when the handler returns nil.
func (*NATSListener) Stream ¶
func (l *NATSListener) Stream() string
Stream returns the JetStream stream the listener consumes from.
func (*NATSListener) Subject ¶
func (l *NATSListener) Subject() string
Subject returns the subject the listener is subscribed to.