broker

package
v1.1.18 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Connect() error
	Disconnect() error
	Publish(string, *Message, ...PublishOption) error
	Subscribe(string, ...SubscribeOption) (Subscription, error)
}

Client is a client interface for various message brokers, e.g., RabbitMQ, Kafka, NATS, etc.

func NewClient

func NewClient(opts ...Option) Client

type Message

type Message struct {
	Header map[string]string
	Body   []byte
}

type Option

type Option func(*Options)

func Secure

func Secure(b bool) Option

Secure communication with the broker

func TLSConfig

func TLSConfig(t *tls.Config) Option

TLSConfig specifies the TLS config

type Options

type Options struct {
	Secure    bool
	TLSConfig *tls.Config
}

type Publication

type Publication interface {
	Topic() string
	Message() *Message
	Ack() error
}

Publication is given to a subscriber for processing

type PublishOption

type PublishOption func(*PublishOptions)

type PublishOptions

type PublishOptions struct {
}

type SubscribeOption

type SubscribeOption func(*SubscribeOptions)

func AutoAck

func AutoAck(enabled bool) SubscribeOption

AutoAck will enable/disable auto acking of messages after they have been handled.

func Queue

func Queue(name string) SubscribeOption

Queue sets the name of the queue to share messages on

type SubscribeOptions

type SubscribeOptions struct {
	// AutoAck defaults to true. When a handler returns
	// with a nil error the message is acked.
	AutoAck bool
	// Subscribers with the same queue name
	// will create a shared subscription where each
	// receives a subset of messages.
	Queue string
}

type Subscription

type Subscription interface {
	Topic() string
	Chan() <-chan Publication
	Unsubscribe() error
}

Subscriber is a convenience return type for the Subscribe method

Jump to

Keyboard shortcuts

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