Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NatsProvider ¶
type NatsProvider struct {
// contains filtered or unexported fields
}
NatsProvider encapsulates a NATS connection, providing methods for publishing messages, subscribing to subjects, and managing connection cleanup.
func NewProvider ¶
func NewProvider(natsConn *nats.Conn) *NatsProvider
NewProvider initializes and returns a new Provider instance with the given NATS connection.
func (*NatsProvider) Cleanup ¶
func (prov *NatsProvider) Cleanup() error
Cleanup gracefully drains and closes the NATS connection, ensuring that all pending messages are sent and resources are released.
func (*NatsProvider) Publish ¶
func (prov *NatsProvider) Publish(subj string, data []byte) error
Publish publishes the data argument to the given subject.
func (*NatsProvider) QueueSubscribe ¶
func (prov *NatsProvider) QueueSubscribe(subj string, queue string, handler nats.MsgHandler) (*nats.Subscription, error)
Subscribe creates an asynchronous queue subscriber on the given subject and queue.
type Provider ¶
type Provider interface { Cleanup() error // Cleanup gracefully shuts down the provider. Publish(subj string, data []byte) error // Publish sends a message to the specified subject. QueueSubscribe(subj string, queue string, handler nats.MsgHandler) (*nats.Subscription, error) // QueueSubscribe subscribes to a subject with a queue group. }
Provider interface defines the basic operations that can be performed with NATS, such as publishing, subscribing, and cleaning up resources.