broker

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

type Broker interface {
	Public(Message) error
	Subscribe()
	UnSubscribe()
}

type Config

type Config struct {
	Name string
	Host string //连接地址
}

type Message

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

type Option

type Option func(*Options)

func Addrs

func Addrs(addrs ...string) Option

Addrs sets the host addresses to be used by the broker.

func Secure

func Secure(b bool) Option

Secure communication with the broker.

func TLSConfig

func TLSConfig(t *tls.Config) Option

Specify TLS Config.

type Options

type Options struct {
	Context context.Context

	TLSConfig *tls.Config
	Addrs     []string
	Secure    bool
}

func NewOptions

func NewOptions(opts ...Option) *Options

type PublishOption

type PublishOption func(*PublishOptions)

func PublishContext

func PublishContext(ctx context.Context) PublishOption

PublishContext set context.

type PublishOptions

type PublishOptions struct {
	// Other options for implementations of the interface
	// can be stored in a context
	Context context.Context
}

type SubscribeOption

type SubscribeOption func(*SubscribeOptions)

func DisableAutoAck

func DisableAutoAck() SubscribeOption

DisableAutoAck will 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.

func SubscribeContext

func SubscribeContext(ctx context.Context) SubscribeOption

SubscribeContext set context.

type SubscribeOptions

type SubscribeOptions struct {

	// Other options for implementations of the interface
	// can be stored in a context
	Context context.Context
	// Subscribers with the same queue name
	// will create a shared subscription where each
	// receives a subset of messages.
	Queue string

	// AutoAck defaults to true. When a handler returns
	// with a nil error the message is acked.
	AutoAck bool
}

func NewSubscribeOptions

func NewSubscribeOptions(opts ...SubscribeOption) SubscribeOptions

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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