nats

package
v0.28.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2022 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*opts)

func WithClientCert

func WithClientCert(certPath, keyPath string) Option

func WithConnectionName

func WithConnectionName(name string) Option

func WithLogger

func WithLogger(logger *zap.Logger) Option

func WithRootCA

func WithRootCA(paths ...string) Option

func WithTimeout

func WithTimeout(timeout time.Duration) Option

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer is a NATS object notification writer. It handles NATS JetStream connections and allows sending string representation of the address to the NATS server.

For correct operation must be created via New function. new(Writer) or Writer{} construction leads to undefined behaviour and is not safe.

func New

func New(ctx context.Context, endpoint string, oo ...Option) (*Writer, error)

New creates and inits new Writer. Connection is closed when passed context is done.

Returns error only if fails to open connection to a NATS server with provided configuration.

func (*Writer) Notify

func (n *Writer) Notify(topic string, address *addressSDK.Address) error

Notify sends object address's string representation to the provided topic. Uses first 4 bytes of object ID as a message ID to support 'exactly once' message delivery.

Returns error only if: 1. underlying connection was closed and has not been established again; 2. NATS server could not respond that it has saved the message.

Jump to

Keyboard shortcuts

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