natsjetstream

package
v0.41.2 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AcknowledgementHandler added in v0.35.0

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

AcknowledgementHandler for nats jetstream broker.

func (AcknowledgementHandler) AckMessage added in v0.35.0

func (k AcknowledgementHandler) AckMessage()

AckMessage acknowledges the message.

func (AcknowledgementHandler) NakMessage added in v0.35.0

func (k AcknowledgementHandler) NakMessage()

NakMessage negatively acknowledges the message.

type Controller

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

Controller is the Controller implementation for asyncapi-codegen.

func NewController

func NewController(url string, options ...ControllerOption) (*Controller, error)

NewController creates a new NATS JetStream controller.

func (*Controller) Close

func (c *Controller) Close()

Close closes everything related to the broker.

func (*Controller) ConsumeIfNeeded

func (c *Controller) ConsumeIfNeeded(ctx context.Context) error

ConsumeIfNeeded starts consuming messages if needed.

func (*Controller) ConsumeMessage

func (c *Controller) ConsumeMessage(ctx context.Context) jetstream.MessageHandler

ConsumeMessage writes the message to the correct channel of the subject or in case there is no subscription the message will be acknowledged.

func (*Controller) HandleMessage

HandleMessage handles a message received from a stream.

func (*Controller) Publish

func (c *Controller) Publish(ctx context.Context, channel string, bm extensions.BrokerMessage) error

Publish a message to the broker.

func (*Controller) StopConsumeIfNeeded

func (c *Controller) StopConsumeIfNeeded()

StopConsumeIfNeeded stops consuming messages if needed (there is no other subscription).

func (*Controller) Subscribe

Subscribe to messages from the broker.

type ControllerOption

type ControllerOption func(controller *Controller) error

ControllerOption is a function that can be used to configure a NATS controller.

func WithConnectionOpts added in v0.36.0

func WithConnectionOpts(opts ...nats.Option) ControllerOption

WithConnectionOpts set the nats.Options to connect to nats.

func WithConsumer

func WithConsumer(name string) ControllerOption

WithConsumer uses the given consumer name (the consumer has to be created before initializing).

func WithConsumerConfig

func WithConsumerConfig(config jetstream.ConsumerConfig) ControllerOption

WithConsumerConfig set consumer configuration for creating or updating a consumer based on the given config.

func WithLogger

func WithLogger(logger extensions.Logger) ControllerOption

WithLogger set a custom logger that will log operations on broker controller.

func WithNakDelay added in v0.35.0

func WithNakDelay(duration time.Duration) ControllerOption

WithNakDelay set the delay when redeliver messages via nak.

func WithStream

func WithStream(name string) ControllerOption

WithStream uses the given stream name (the stream has to be created before initializing).

func WithStreamConfig

func WithStreamConfig(config jetstream.StreamConfig) ControllerOption

WithStreamConfig add the stream configuration for creating or updating a stream based on the given configuration.

Jump to

Keyboard shortcuts

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