nats

package
v0.0.23 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewNats

func NewNats(log logger.Logger, name string, hosts string, credentials gnats.Option, opts ...gnats.Option) (*gnats.Conn, error)

NewNats will return a new nats connections

Types

type EphemeralConsumerConfig added in v0.0.23

type EphemeralConsumerConfig struct {
	Context             context.Context
	Logger              logger.Logger
	JetStream           nats.JetStreamContext
	StreamName          string
	ConsumerDescription string
	FilterSubject       string
	Handler             Handler
	DeliverPolicy       nats.DeliverPolicy
	Deliver             nats.SubOpt
}

type ExactlyOnceConsumerConfig added in v0.0.17

type ExactlyOnceConsumerConfig struct {
	Context             context.Context
	Logger              logger.Logger
	JetStream           nats.JetStreamContext
	StreamName          string
	DurableName         string
	ConsumerDescription string
	FilterSubject       string
	Handler             Handler
	DeliverPolicy       nats.DeliverPolicy
	Deliver             nats.SubOpt
	MaxAckPending       int
}

type Handler added in v0.0.22

type Handler func(ctx context.Context, payload []byte, msg *nats.Msg) error

type QueueConsumerConfig added in v0.0.22

type QueueConsumerConfig struct {
	Context             context.Context
	Logger              logger.Logger
	JetStream           nats.JetStreamContext
	StreamName          string
	DurableName         string
	ConsumerDescription string
	FilterSubject       string
	Handler             Handler
	DeliverPolicy       nats.DeliverPolicy
	Deliver             nats.SubOpt
}

type Subscriber added in v0.0.22

type Subscriber interface {
	// Close the subscriber and stop delivery
	Close() error
}

Subscriber represents a nats subscriber

func NewEphemeralConsumer added in v0.0.23

func NewEphemeralConsumer(ctx context.Context, logger logger.Logger, js nats.JetStreamContext, stream string, description string, subject string, handler Handler) (Subscriber, error)

NewEphemeralConsumer will create (or reuse) an ephemeral consumer with default config

func NewEphemeralConsumerDeliverAll added in v0.0.23

func NewEphemeralConsumerDeliverAll(ctx context.Context, logger logger.Logger, js nats.JetStreamContext, stream string, description string, subject string, handler Handler) (Subscriber, error)

NewEphemeralConsumerDeliverAll will create (or reuse) an ephemeral consumer with default config which will deliver all messages (not just new ones)

func NewEphemeralConsumerWithConfig added in v0.0.23

func NewEphemeralConsumerWithConfig(config EphemeralConsumerConfig) (Subscriber, error)

NewEphemeralConsumerWithConfig will create (or reuse) ephemeral consumer

func NewExactlyOnceConsumer added in v0.0.3

func NewExactlyOnceConsumer(ctx context.Context, logger logger.Logger, js nats.JetStreamContext, stream string, durable string, description string, subject string, handler Handler) (Subscriber, error)

NewExactlyOnceConsumer will create (or reuse) an exactly once durable consumer

func NewExactlyOnceConsumerWithConfig added in v0.0.17

func NewExactlyOnceConsumerWithConfig(config ExactlyOnceConsumerConfig) (Subscriber, error)

NewExactlyOnceConsumer will create (or reuse) an exactly once durable consumer

func NewQueueConsumer added in v0.0.22

func NewQueueConsumer(ctx context.Context, logger logger.Logger, js nats.JetStreamContext, stream string, durable string, description string, subject string, handler Handler) (Subscriber, error)

NewQueueConsumer will create (or reuse) a queue consumer with default config

func NewQueueConsumerWithConfig added in v0.0.22

func NewQueueConsumerWithConfig(config QueueConsumerConfig) (Subscriber, error)

NewQueueConsumerWithConfig will create (or reuse) queue consumer

Jump to

Keyboard shortcuts

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