Documentation ¶
Index ¶
- Variables
- type EventEnvelope
- type EventMeta
- type EventSource
- type Eventbus
- func (bus *Eventbus) Close()
- func (bus *Eventbus) Publish(ctx app.Context, event interface{}, meta EventMeta) error
- func (bus *Eventbus) PublishTx(ctx app.Context, event interface{}, meta EventMeta, tx *sql.Tx) (PublishContinuation, error)
- func (bus *Eventbus) Subscribe(source EventSource) <-chan EventEnvelope
- type PublishContinuation
Constants ¶
This section is empty.
Variables ¶
var (
ErrBusClosed = errors.New("eventbus is closed")
)
Functions ¶
This section is empty.
Types ¶
type EventEnvelope ¶
type EventMeta ¶
type EventMeta struct { EventVersion uint SourceType EventSource SourceId string }
type EventSource ¶
type EventSource string
type Eventbus ¶
type Eventbus struct {
// contains filtered or unexported fields
}
func NewEventbus ¶
NewEventbus creates a new event bus. The event bus is backed by a SQL database and uses the provided clock to timestamp events. It is basically functioning as both a pubsub and an event store.
func (*Eventbus) Publish ¶
Publish publishes an event to the event bus. The event will be stored in the database and sent to all subscribers of the event source.
func (*Eventbus) PublishTx ¶
func (bus *Eventbus) PublishTx(ctx app.Context, event interface{}, meta EventMeta, tx *sql.Tx) (PublishContinuation, error)
PublishTx publishes an event to the event bus. The event will be stored in the database and sent to all subscribers of the event source. The event will be published when the returned PublishContinuation is called. This allows the caller to publish the event after a transaction has been committed.
func (*Eventbus) Subscribe ¶
func (bus *Eventbus) Subscribe(source EventSource) <-chan EventEnvelope
Subscribe subscribes to events from a given source. The returned channel will receive all events published by the source.
type PublishContinuation ¶
type PublishContinuation func()