broker

package
v0.0.0-...-2d343b4 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2022 License: MIT Imports: 3 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 {
	Init(...Option) error
	Options() Options
	Address() string
	Connect() error
	Disconnect() error
	Publish(topic string, m *Message, opts ...PublishOption) error
	Subscribe(topic string, h Handler, opts ...SubscribeOption) (Subscriber, error)
	Name() string
}

type EchoHandler

type EchoHandler func(context.Context, Event) (Event, error)

type Event

type Event interface {
	Topic() string
	Message() *Message
	Ack() error
	Reply(m *Message)
	Error() error
}

type Handler

type Handler func(context.Context, Event) error

type Message

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

type Option

type Option func(*Options)

func Addrs

func Addrs(addrs ...string) Option

func Codec

func Codec(c codec.Marshaler) Option

func ErrorHandler

func ErrorHandler(h Handler) Option

func OptionContext

func OptionContext(ctx context.Context) Option

func OptionContextWithValue

func OptionContextWithValue(k, v interface{}) Option

func Secure

func Secure(b bool) Option

func TLSConfig

func TLSConfig(t *tls.Config) Option

type Options

type Options struct {
	Addrs []string
	Codec codec.Marshaler

	ErrorHandler Handler

	Secure    bool
	TLSConfig *tls.Config

	Context context.Context
}

func NewOptions

func NewOptions() Options

func NewOptionsAndApply

func NewOptionsAndApply(opts ...Option) Options

func (*Options) Apply

func (o *Options) Apply(opts ...Option)

type PublishOption

type PublishOption func(*PublishOptions)

func PublishContext

func PublishContext(ctx context.Context) PublishOption

func PublishContextWithValue

func PublishContextWithValue(k, v interface{}) PublishOption

type PublishOptions

type PublishOptions struct {
	Context context.Context
}

func NewPublishOptions

func NewPublishOptions(opts ...PublishOption) PublishOptions

func (*PublishOptions) Apply

func (o *PublishOptions) Apply(opts ...PublishOption)

type SubscribeOption

type SubscribeOption func(*SubscribeOptions)

func DisableAutoAck

func DisableAutoAck() SubscribeOption

func Queue

func Queue(name string) SubscribeOption

func SubscribeContext

func SubscribeContext(ctx context.Context) SubscribeOption

func SubscribeContextWithValue

func SubscribeContextWithValue(k, v interface{}) SubscribeOption

type SubscribeOptions

type SubscribeOptions struct {
	AutoAck bool
	Queue   string
	Context context.Context
}

func NewSubscribeOptions

func NewSubscribeOptions(opts ...SubscribeOption) SubscribeOptions

func (*SubscribeOptions) Apply

func (o *SubscribeOptions) Apply(opts ...SubscribeOption)

type Subscriber

type Subscriber interface {
	Options() SubscribeOptions
	Topic() string
	Unsubscribe() error
}

Directories

Path Synopsis
Package rabbitmq provides a RabbitMQ common
Package rabbitmq provides a RabbitMQ common

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳