Documentation ¶
Index ¶
- type ClientPool
- type NATSClient
- func (c *NATSClient) BindKVStore(kvName string) (nats.KeyValue, error)
- func (c *NATSClient) Close()
- func (c *NATSClient) JetStreamContext(opts ...nats.JSOpt) (nats.JetStreamContext, error)
- func (c *NATSClient) PendingForStream(consumer string, stream string) (int64, error)
- func (c *NATSClient) Subscribe(subject string, stream string, opts ...nats.SubOpt) (*nats.Subscription, error)
- type Option
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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() *NATSClient
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 NATSClient ¶ added in v0.9.0
NATSClient 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) (*NATSClient, error)
NewNATSClient Create a new NATS client
func NewTestClient ¶ added in v0.9.0
func NewTestClient(t *testing.T, url string) *NATSClient
NewTestClient creates a new NATS client for testing only use this for testing
func (*NATSClient) BindKVStore ¶ added in v0.9.0
func (c *NATSClient) BindKVStore(kvName string) (nats.KeyValue, error)
BindKVStore lookup and bind to an existing KeyValue store and return the KeyValue interface
func (*NATSClient) Close ¶ added in v0.9.0
func (c *NATSClient) Close()
Close closes the NATS client
func (*NATSClient) JetStreamContext ¶ added in v0.9.0
func (c *NATSClient) JetStreamContext(opts ...nats.JSOpt) (nats.JetStreamContext, error)
JetStreamContext returns a new JetStreamContext
func (*NATSClient) PendingForStream ¶ added in v0.9.0
func (c *NATSClient) PendingForStream(consumer string, stream string) (int64, error)
PendingForStream returns the number of pending messages for the given consumer and stream
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
WithClientPoolSize sets the size of the NATS client pool