Documentation ¶
Overview ¶
Package pubsub is an abstraction of any publisher-subscriber mechanism.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorHandler ¶
ErrorHandler should handle the given error and deal with the optional event if necessary.
type Event ¶
type Event struct { // ID holds the event unique ID, to be used for idempotency purposes. ID ID `json:"id"` // Name indicates the event name or type. Name Name `json:"name"` // Meta encapsulates contextual information. Meta Meta `json:"meta"` // Payload holds the actual event message. Payload []byte `json:"payload"` }
Event defines the event envelope.
type Meta ¶
type Meta struct { // CreatedAtUTC indicates the UTC time when the event was created. CreatedAtUTC time.Time `json:"created_at_utc"` // CorrelationID holds the request correlation ID. CorrelationID string `json:"correlation_id"` // Attempts indicates how many times the event has been handled. Attempts int `json:"attempts"` // IsDryRun indicates whether the execution is a dry run. IsDryRun bool `json:"is_dry_run"` }
Meta encapsulates execution information.
type Publisher ¶
type Publisher interface { // Emit publishes the given events to the stream. Emit(context.Context, ...Event) error // Close should close any underlying connection. Close() error }
Publisher defines the capabilities of any publisher.
type Subscriber ¶
type Subscriber interface { // Consume takes a single event from the stream and processes it using the // given handler. The event will be sent to the error handler in case of // failure. Consume(context.Context, Handler, ErrorHandler) // Close should close any underlying connection. Close() error }
Subscriber defines the capabilities of any subscriber.
Click to show internal directories.
Click to hide internal directories.