nats

package
v0.28.3 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 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(oo ...Option) *Writer

New creates new Writer.

func (*Writer) Connect

func (n *Writer) Connect(ctx context.Context, endpoint string) error

Connect tries to connect to a specified NATS endpoint.

Connection is closed when passed context is done.

func (*Writer) Notify

func (n *Writer) Notify(topic string, address oid.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