nats

package
v0.0.0-...-3f93e99 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2023 License: GPL-3.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotConnected = errors.New("nats: not connected")
)

Errors

Functions

This section is empty.

Types

type Connection

type Connection struct {
	sync.Mutex
	logger.Logger
	// contains filtered or unexported fields
}

Connection interface

func CreateConnection

func CreateConnection(opts ...Option) *Connection

CreateConnection creates new connection

func (*Connection) Connect

func (c *Connection) Connect() error

Connect to broker

func (*Connection) Disconnect

func (c *Connection) Disconnect()

Disconnect from broker

func (*Connection) IsConnected

func (c *Connection) IsConnected() bool

IsConnected status

func (*Connection) Publish

func (c *Connection) Publish(topic string, message []byte) error

Publish message

func (*Connection) Status

func (c *Connection) Status() <-chan struct{}

Status of connection

func (*Connection) Subscribe

func (c *Connection) Subscribe(topic string, queue string, handler bus.MessageHandler) (interface{}, error)

Subscribe for messages

func (*Connection) Unsubscribe

func (c *Connection) Unsubscribe(handle interface{}) error

Unsubscribe subscription

type Option

type Option func(*options)

Option initializes Options properties

func WithCloseHandler

func WithCloseHandler(h nats.ConnHandler) Option

WithCloseHandler initializes closeHandler option

func WithDisconnectHandler

func WithDisconnectHandler(h nats.ConnHandler) Option

WithDisconnectHandler initializes disconnectHandler option

func WithLogger

func WithLogger(l logger.Logger) Option

WithLogger initializes logger option

func WithName

func WithName(n string) Option

WithName initializes name option

func WithReconnectDelay

func WithReconnectDelay(t time.Duration) Option

WithReconnectDelay initializes reconnectDelay option

func WithReconnectHandler

func WithReconnectHandler(h nats.ConnHandler) Option

WithReconnectHandler initializes reconnectHandler option

func WithURL

func WithURL(u string) Option

WithURL initializes url option

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL