Documentation
¶
Index ¶
Constants ¶
View Source
const (
DefaultName = "mkit.broker.default"
)
Variables ¶
This section is empty.
Functions ¶
func AddSubscriber ¶ added in v0.2.0
func AddSubscriber(subscription string, handler Handler, opts ...SubscribeOption) error
Types ¶
type Broker ¶
type Broker interface { NewPublisher(topic string, opts ...PublishOption) (pub Publisher, err error) AddSubscriber(subscription string, hdlr Handler, opts ...SubscribeOption) (err error) Start() error }
Broker is an interface used for asynchronous messaging.
var DefaultBroker Broker
type Handler ¶ added in v0.1.2
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)
type PublishOption ¶ added in v0.1.2
type PublishOption func(*PublishOptions)
func PublishAsync ¶ added in v0.1.2
func PublishAsync(b bool) PublishOption
type PublishOptions ¶ added in v0.1.2
type PublishOptions struct { // publishes msg to the topic asynchronously if set to true. // Default false. i.e., publishes synchronously(blocking) Async bool }
type Publisher ¶ added in v0.1.2
func NewPublisher ¶ added in v0.2.0
func NewPublisher(topic string, opts ...PublishOption) (Publisher, error)
type RecoveryHandler ¶ added in v0.2.0
RecoveryHandler is a function that is called when the recovery middleware recovers from a panic. The func takes the receive context, message and the return value from recover which reports whether the goroutine is panicking. Example usages of HandlerFunc could be to log panics or nack/ack messages which cause panics.
type SubscribeOption ¶ added in v0.1.2
type SubscribeOption func(*SubscribeOptions)
func WithRecoveryHandler ¶ added in v0.2.0
func WithRecoveryHandler(r RecoveryHandler) SubscribeOption
WithRecoveryHandler sets the function for recovering from a panic.
type SubscribeOptions ¶ added in v0.1.2
type SubscribeOptions struct {
RecoveryHandler RecoveryHandler
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.