Documentation ¶
Index ¶
- Variables
- func NewGracefulContext(ctx context.Context, idle, forceAfter time.Duration) (c context.Context, keepAlive func(), cancel func())
- type GracefulContext
- type Option
- type Outbox
- func (o *Outbox) AddHandler(ctx context.Context, m eh.EventMatcher, h eh.EventHandler) error
- func (o *Outbox) Client() *mongo.Client
- func (o *Outbox) Close() error
- func (o *Outbox) Errors() <-chan error
- func (o *Outbox) HandleEvent(ctx context.Context, event eh.Event) error
- func (o *Outbox) HandlerType() eh.EventHandlerType
- func (o *Outbox) Start()
Constants ¶
This section is empty.
Variables ¶
var ( // Interval in which to do a sweep of various unprocessed events. PeriodicSweepInterval = 15 * time.Second // Settings for how old different kind of unprocessed events needs to be // to be processed by the periodic sweep. PeriodicSweepAge = 15 * time.Second PeriodicCleanupAge = 10 * time.Minute )
Functions ¶
func NewGracefulContext ¶
func NewGracefulContext(ctx context.Context, idle, forceAfter time.Duration) ( c context.Context, keepAlive func(), cancel func(), )
NewGracefulContext will create a GracefulContext with an idle time which should be longer than a typical operation cadence, and a "force after" duration which should be long enough to let some amount of operations to finish.
Types ¶
type GracefulContext ¶
GracefulContext is a context that can be gracefully cancelled after the original context has been canceled, but with a grace period to let operations finish. The KeepAlive method should be used to signal that operations are still ongoing.
func (*GracefulContext) Done ¶
func (g *GracefulContext) Done() <-chan struct{}
Done implements the Done method of the context.Context interface.
type Option ¶
Option is an option setter used to configure creation.
func WithWatchToken ¶
WithWatchToken sets a token, used for watching outbox events stored with the same token. This can be used to let parts of a system watch their own events by setting a common token, for example a service name. If each host should watch their local events the hostname can often be used.
type Outbox ¶
type Outbox struct {
// contains filtered or unexported fields
}
Outbox implements an eventhorizon.Outbox for MongoDB.
func NewOutboxWithClient ¶
NewOutboxWithClient creates a new Outbox with a client.
func (*Outbox) AddHandler ¶
func (o *Outbox) AddHandler(ctx context.Context, m eh.EventMatcher, h eh.EventHandler) error
AddHandler implements the AddHandler method of the eventhorizon.Outbox interface.
func (*Outbox) Client ¶
Client returns the MongoDB client used by the outbox. To use the outbox with the EventStore it needs to be created with the same client.
func (*Outbox) HandleEvent ¶
HandleEvent implements the HandleEvent method of the eventhorizon.EventHandler interface.
func (*Outbox) HandlerType ¶
func (o *Outbox) HandlerType() eh.EventHandlerType
HandlerType implements the HandlerType method of the eventhorizon.EventHandler interface.