natsjetstream

package
v0.0.4-vb Latest Latest
Warning

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

Go to latest
Published: Apr 10, 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

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

AcknowledgementHandler for nats jetstream broker.

func (AcknowledgementHandler) AckMessage

func (k AcknowledgementHandler) AckMessage()

AckMessage acknowledges the message.

func (AcknowledgementHandler) NakMessage

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 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 creates or updates a consumer based on the given consumer configuration.

func WithLogger

func WithLogger(logger extensions.Logger) ControllerOption

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

func WithNakDelay

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 creates or updates a stream based on the given stream configuration.

Jump to

Keyboard shortcuts

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