Documentation ¶
Overview ¶
Package broker is an interface used for asynchronous messaging
Index ¶
- func Connect() *errorAVA.Error
- func Disconnect() *errorAVA.Error
- func Init(opts ...Option) *errorAVA.Error
- func Publish(topic string, msg *Message, opts ...PublishOption) *errorAVA.Error
- func String() string
- type BrokerI
- type EventI
- type Handler
- type Message
- type Option
- type Options
- type PublishOption
- type PublishOptions
- type SubscribeOption
- type SubscribeOptions
- type SubscriberI
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Disconnect ¶
Types ¶
type BrokerI ¶
type BrokerI interface { Init(...Option) *errorAVA.Error Options() Options Address() string Connect() *errorAVA.Error Disconnect() *errorAVA.Error Publish(topic string, m *Message, opts ...PublishOption) *errorAVA.Error Subscribe(topic string, h Handler, opts ...SubscribeOption) (SubscriberI, *errorAVA.Error) String() string }
Broker is an interface used for asynchronous messaging.
var (
DefaultBroker BrokerI = NewBroker()
)
type Handler ¶
Handler is used to process messages via a subscription of a topic. The handler is passed a publication interface which contains the message and optional Ack method to acknowledge receipt of the message.
type Option ¶
type Option func(*Options)
func Codec ¶
Codec sets the codec used for encoding/decoding used where a broker does not support headers
func ErrorHandler ¶
ErrorHandler will catch all broker errors that cant be handled in normal way, for example Codec errors
type Options ¶
type Options struct { Addrs []string Secure bool Codec codec.Marshaler // Handler executed when error happens in broker mesage // processing ErrorHandler Handler TLSConfig *tls.Config // Registry used for clustering Registry registry.RegistryI // Other options for implementations of the interface // can be stored in a context Context context.Context }
type PublishOption ¶
type PublishOption func(*PublishOptions)
type PublishOptions ¶
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 { // 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 // Other options for implementations of the interface // can be stored in a context Context context.Context }
func NewSubscribeOptions ¶
func NewSubscribeOptions(opts ...SubscribeOption) SubscribeOptions
type SubscriberI ¶
type SubscriberI interface { Options() SubscribeOptions Topic() string Unsubscribe() error }
Subscriber is a convenience return type for the Subscribe method
func Subscribe ¶
func Subscribe(topic string, handler Handler, opts ...SubscribeOption) (SubscriberI, *errorAVA.Error)