nats

package
v1.2.0-rc4 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client added in v1.1.6

type Client struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Client is a client for NATS server which be shared by multiple connections (reader, writer, kv, buffer management, etc.)

func NewNATSClient added in v0.9.0

func NewNATSClient(ctx context.Context, natsOptions ...nats.Option) (*Client, error)

NewNATSClient Create a new NATS client

func NewTestClient added in v0.9.0

func NewTestClient(t *testing.T, url string) *Client

NewTestClient creates a new NATS client for testing only use this for testing

func (*Client) BindKVStore added in v1.1.6

func (c *Client) BindKVStore(kvName string) (nats.KeyValue, error)

BindKVStore lookup and bind to an existing KeyValue store and return the KeyValue interface

func (*Client) Close added in v1.1.6

func (c *Client) Close()

Close closes the NATS client

func (*Client) JetStreamContext added in v1.1.6

func (c *Client) JetStreamContext(opts ...nats.JSOpt) (nats.JetStreamContext, error)

JetStreamContext returns a new JetStreamContext

func (*Client) PendingForStream added in v1.1.6

func (c *Client) PendingForStream(consumer string, stream string) (int64, error)

PendingForStream returns the number of pending messages for the given consumer and stream

func (*Client) Subscribe added in v1.1.6

func (c *Client) Subscribe(subject string, stream string, opts ...nats.SubOpt) (*nats.Subscription, error)

Subscribe returns a subscription for the given subject and stream

type ClientPool added in v0.9.0

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

ClientPool is a pool of NATS clients used on at the initial create connection phase.

func NewClientPool added in v0.9.0

func NewClientPool(ctx context.Context, opts ...Option) (*ClientPool, error)

NewClientPool returns a new pool of NATS clients of the given size

func (*ClientPool) CloseAll added in v0.9.0

func (p *ClientPool) CloseAll()

CloseAll closes all the clients in the pool

func (*ClientPool) NextAvailableClient added in v0.9.0

func (p *ClientPool) NextAvailableClient() *Client

NextAvailableClient returns the next available NATS client. This code need not be optimized because this is not in hot code path. It is only during connection creation/startup.

type Option added in v0.9.0

type Option func(*Options)

Option is a function on the options for a NATS client pool

func WithClientPoolSize added in v0.9.0

func WithClientPoolSize(size int) Option

WithClientPoolSize sets the size of the NATS client pool

type Options added in v0.9.0

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

Options for NATS client pool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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