nats

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package nats provides a Vice implementation for NATS.

Index

Constants

View Source
const DefaultAddr = nats.DefaultURL

DefaultAddr is the NATS default TCP address.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Options)

Option is a function on the options for a nats transport.

func WithConnection

func WithConnection(c *nats.Conn) Option

WithConnection is an Option to set underlying nats connection.

func WithStreaming

func WithStreaming(clusterID, clientID string) Option

WithStreaming is an Option to activate nats streaming for the transport.

type Options

type Options struct {
	Conn               *nats.Conn
	StreamingClusterID string
	StreamingClientID  string
	UseStreaming       bool
}

Options can be used to create a customized transport.

type Transport

type Transport struct {
	sync.Mutex

	// exported fields
	NatsAddr string
	// contains filtered or unexported fields
}

Transport is a vice.Transport for NATS queue.

func New

func New(opts ...Option) *Transport

New returns a new Transport

func (*Transport) Done

func (t *Transport) Done() chan struct{}

Done gets a channel which is closed when the transport has successfully stopped.

func (*Transport) ErrChan

func (t *Transport) ErrChan() <-chan error

ErrChan gets the channel on which errors are sent.

func (*Transport) Receive

func (t *Transport) Receive(name string) <-chan []byte

Receive gets a channel on which to receive messages with the specified name.

func (*Transport) Send

func (t *Transport) Send(name string) chan<- []byte

Send gets a channel on which messages with the specified name may be sent.

func (*Transport) Stop

func (t *Transport) Stop()

Stop stops the transport. The channel returned from Done() will be closed when the transport has stopped.

Jump to

Keyboard shortcuts

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