Documentation ¶
Overview ¶
The nats package provides a NATS implementation of the pubsub interface.
Index ¶
- Constants
- func Get() pubsub.IPubSub
- func New(ctx context.Context, url string, options ...Option) (pubsub.IPubSub, error)
- func Set(ps pubsub.IPubSub)
- type NATS
- func (n *NATS) Close() error
- func (n *NATS) GetClient() any
- func (n *NATS) MustPublish(ctx context.Context, msgs ...*message.Message) []*message.Message
- func (n *NATS) MustPublishAsync(ctx context.Context, messages ...*message.Message)
- func (n *NATS) MustSubscribe(ctx context.Context, subscriptions ...*subscription.Subscription) []*subscription.Subscription
- func (n *NATS) MustSubscribeAsync(ctx context.Context, subscriptions ...*subscription.Subscription)
- func (n *NATS) Publish(ctx context.Context, messages []*message.Message, opts ...pubsub.Func) ([]*message.Message, concurrentloop.Errors)
- func (n *NATS) Subscribe(ctx context.Context, subscriptions []*subscription.Subscription, ...) ([]*subscription.Subscription, concurrentloop.Errors)
- func (n *NATS) Unsubscribe(ctx context.Context, subscriptions ...*subscription.Subscription) error
- type Option
Constants ¶
View Source
const Name = "nats"
Name is the name of the pubsub.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type NATS ¶
type NATS struct { *pubsub.PubSub // Options are the NATS configuration. Options []Option `json:"-" validate:"required"` // Client is the NATS client. Client *natsgo.Conn // URL is the NATS URL. URL string `json:"url" validate:"required"` }
NATS pubsub definition.
func (*NATS) GetClient ¶
GetClient returns the storage client. Use that to interact with the underlying storage client.
func (*NATS) MustPublish ¶ added in v1.0.14
MustPublish sends a message to a topic. In case of error it will panic.
func (*NATS) MustPublishAsync ¶ added in v1.0.14
MustPublishAsync sends a message to a topic asynchronously. In case of error it will panic.
func (*NATS) MustSubscribe ¶ added in v1.0.14
func (n *NATS) MustSubscribe(ctx context.Context, subscriptions ...*subscription.Subscription) []*subscription.Subscription
MustSubscribe to a topic. In case of error it will panic.
func (*NATS) MustSubscribeAsync ¶ added in v1.0.21
func (n *NATS) MustSubscribeAsync(ctx context.Context, subscriptions ...*subscription.Subscription)
MustSubscribeAsync to a topic asynchronously. In case of error it will panic.
func (*NATS) Publish ¶
func (n *NATS) Publish( ctx context.Context, messages []*message.Message, opts ...pubsub.Func, ) ([]*message.Message, concurrentloop.Errors)
Publish sends a message to a topic.
func (*NATS) Subscribe ¶
func (n *NATS) Subscribe( ctx context.Context, subscriptions []*subscription.Subscription, opts ...pubsub.Func, ) ([]*subscription.Subscription, concurrentloop.Errors)
Subscribe to a topic.
func (*NATS) Unsubscribe ¶
func (n *NATS) Unsubscribe(ctx context.Context, subscriptions ...*subscription.Subscription) error
Unsubscribe from a topic.
Click to show internal directories.
Click to hide internal directories.