Documentation
¶
Overview ¶
Package events provides the eventer object which is responsible for setting up the watermill router and handling the incoming events
Index ¶
- Constants
- type AggregatorMiddleware
- type Consumer
- type Eventer
- func (e *Eventer) Close() error
- func (e *Eventer) ConsumeEvents(consumers ...Consumer)
- func (e *Eventer) Publish(topic string, messages ...*message.Message) error
- func (e *Eventer) Register(topic string, handler message.NoPublishHandlerFunc, ...)
- func (e *Eventer) Run(ctx context.Context) error
- func (e *Eventer) Running() chan struct{}
- type Handler
- type Registrar
Constants ¶
const ( ProviderDeliveryIdKey = "id" ProviderTypeKey = "provider" ProviderSourceKey = "source" GithubWebhookEventTypeKey = "type" GoChannelDriver = "go-channel" SQLDriver = "sql" DeadLetterQueueTopic = "dead_letter_queue" PublishedKey = "published_at" )
Metadata added to Messages
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AggregatorMiddleware ¶ added in v0.0.17
type AggregatorMiddleware interface {
AggregateMiddleware(h message.HandlerFunc) message.HandlerFunc
}
AggregatorMiddleware is an interface that allows the eventer to add middleware to the router
type Consumer ¶
type Consumer interface {
Register(Registrar)
}
Consumer is an interface implemented by components which wish to consume events. Once a component has implemented the consumer interface, it can be registered with an event router using the HandleAll interface.
type Eventer ¶
type Eventer struct {
// contains filtered or unexported fields
}
Eventer is a wrapper over the relevant eventing objects in such a way that they can be easily accessible and configurable.
func Setup ¶
func Setup(ctx context.Context, cfg *serverconfig.EventConfig) (*Eventer, error)
Setup creates an Eventer object which isolates the watermill setup code
func (*Eventer) ConsumeEvents ¶
ConsumeEvents allows registration of multiple consumers easily
func (*Eventer) Register ¶
func (e *Eventer) Register( topic string, handler message.NoPublishHandlerFunc, mdw ...message.HandlerMiddleware, )
Register subscribes to a topic and handles incoming messages
type Handler ¶
type Handler = message.NoPublishHandlerFunc
Handler is an alias for the watermill handler type, which is both wordy and may be detail we don't want to expose.
type Registrar ¶
type Registrar interface {
// Register requests that the message router calls handler for each message on topic.
// It is valid to call Register multiple times with the same topic and different handler
// functions, or to call Register multiple times with different topics and the same
// handler function. It's allowed to call Register with both argument the same, but
// then events will be delivered twice to the handler, which is probably not what you want.
Register(topic string, handler Handler, mdw ...message.HandlerMiddleware)
// HandleAll registers all the consumers with the registrar
// TODO: should this be a different interface?
ConsumeEvents(consumers ...Consumer)
}
Registrar provides an interface which allows an event router to expose itself to event consumers.