Documentation
¶
Index ¶
- Constants
- type Broker
- func (b *Broker) DeregisterHandler(key string)
- func (b *Broker) DeregisterTopics(topics ...string)
- func (b *Broker) Emit(ctx context.Context, topic string, data interface{}) error
- func (b *Broker) EmitWithOpts(ctx context.Context, topic string, data interface{}, options ...MessageOption) error
- func (b *Broker) HandlerKeys() []string
- func (b *Broker) HandlerTopicSubscriptions(handlerKey string) []string
- func (b *Broker) RegisterHandler(key string, h Handler)
- func (b *Broker) RegisterTopics(topics ...string)
- func (b *Broker) TopicHandlerKeys(topic string) []string
- func (b *Broker) Topics() []string
- type BrokerError
- type Handler
- type IDGenerator
- type Message
- type MessageOption
- type Next
- type Sequential
Constants ¶
const ( // CtxKeyTxID tx id context key CtxKeyTxID = ctxKey(116) // CtxKeySource source context key CtxKeySource = ctxKey(117) )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Broker ¶
type Broker struct {
// contains filtered or unexported fields
}
Broker controls the message bus
func (*Broker) DeregisterHandler ¶
DeregisterHandler deletes handler from the registry
func (*Broker) DeregisterTopics ¶
DeregisterTopics deletes topic
func (*Broker) Emit ¶
Emit inits a new message and delivers to the interested in handlers with sync safety
func (*Broker) EmitWithOpts ¶
func (b *Broker) EmitWithOpts(ctx context.Context, topic string, data interface{}, options ...MessageOption, ) error
EmitWithOpts inits a new message and delivers to the interested in handlers with sync safety and options
func (*Broker) HandlerKeys ¶
HandlerKeys returns list of registered handler keys
func (*Broker) HandlerTopicSubscriptions ¶
HandlerTopicSubscriptions returns all topic subscriptions of the handler
func (*Broker) RegisterHandler ¶
RegisterHandler re/register the handler to the registry
func (*Broker) RegisterTopics ¶
RegisterTopics registers topics and fulfills handlers
func (*Broker) TopicHandlerKeys ¶
TopicHandlerKeys returns all handlers for the topic
type BrokerError ¶
type BrokerError struct {
// contains filtered or unexported fields
}
func (*BrokerError) Error ¶
func (e *BrokerError) Error() string
type Handler ¶
type Handler struct { // handler func to process messages Handle func(ctx context.Context, m Message) // topic matcher as regex pattern Matcher string // contains filtered or unexported fields }
Handler is a receiver for message reference with the given regex pattern
type IDGenerator ¶
type IDGenerator interface {
Generate() string
}
IDGenerator is a sequential unique id generator interface
type Message ¶
type Message struct { ID string // identifier TxID string // transaction identifier Topic string // topic name Source string // source of the message OccurredAt time.Time // inception time in nanoseconds Data interface{} // actual message data }
Message is data structure for any logs
type MessageOption ¶
MessageOption is a function type to mutate message fields
func WithID ¶
func WithID(id string) MessageOption
WithID returns an option to set message's id field
func WithOccurredAt ¶
func WithOccurredAt(t time.Time) MessageOption
WithOccurredAt returns an option to set message's occurredAt field
func WithSource ¶
func WithSource(source string) MessageOption
WithSource returns an option to set message's source field
func WithTxID ¶
func WithTxID(txID string) MessageOption
WithTxID returns an option to set message's txID field
type Sequential ¶
type Sequential struct { Format string // contains filtered or unexported fields }
func (*Sequential) Generate ¶
func (g *Sequential) Generate() string