nats

package
v0.0.0-...-60e2cca Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrIncompatibleConsumer = errors.New("nats: cannot subscribe to a pull consumer")
)

Functions

This section is empty.

Types

type Client

type Client interface {
	Close()
	StreamName() string
	IsConnected() bool
	JetStreamCreateStream(streamName string) error
	GetConsumerConfig(name string) (*ConsumerConfig, error)
	CreateConsumer(name string, upsert bool, config ConsumerConfig) error
	JetStreamSubscribe(
		ctx context.Context,
		subj,
		durable string,
		q chan *natsio.Msg,
	) (UnsubscribeFunc, error)
	JetStreamPublish(string, []byte) error
}

Client is the nats client

func NewClient

func NewClient(url string, streamName string, opts ...natsio.Option) (Client, error)

NewClient returns a new nats client

func NewClientWithDefaults

func NewClientWithDefaults(url string, streamName string) (Client, error)

NewClient returns a new nats client with default options

type ConsumerConfig

type ConsumerConfig struct {
	// Filter expression for which topics this consumer covers.
	Filter string
	// MaxPending messages in the work queue.
	// NOTE: This sets an upper limit on the horizontal scalability of the
	// service.
	MaxPending int
	// MaxDeliver sets the maximum amount of time the message will be
	// (re-) delivered.
	MaxDeliver int
	// AckWait sets the time to wait for message acknowledgement before
	// resending the message.
	AckWait time.Duration
}

func (ConsumerConfig) Validate

func (cfg ConsumerConfig) Validate() error

type UnsubscribeFunc

type UnsubscribeFunc func() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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