Documentation
¶
Overview ¶
Package event provides types for publishing and consuming events from event buses.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Envelope ¶
type Envelope struct { // A unique identifier for the event. ID string `json:"id"` // The time the event was published. Timestamp time.Time `json:"timestamp"` // Denotes the structure of the Payload field and the type to use for decoding. Type string `json:"type"` // The raw JSON of the event payload. Payload json.RawMessage `json:"payload"` }
The Envelope type describes the structure of events published to and read from an event bus.
type Payload ¶
type Payload interface { // Type should return a string unique to the event type. Type() string // Key should return a string used to preserve ordering of events. Key() string }
The Payload interface describes types that can be used as event payloads.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
The Reader type is used to consume messages from an event bus.
func NewReader ¶
NewReader returns a new instance of the Reader type that will consume events as described in its URL string. See the gocloud.dev documentation for more information on provider specific urls.
func (*Reader) Check ¶ added in v0.9.0
Check returns the last non-nil error when trying to read an event. This method is used to implement the operation.Checker interface for use in health checks.
func (*Reader) Name ¶ added in v0.9.0
Name returns "event-reader" This method is used to implement the operation.Checker interface for use in health checks.
func (*Reader) Read ¶
Read messages from the event bus whose types appear in the types parameter. For each event, the Handler is invoked. If the handler returns an error, the message is nack'd where supported by the event bus. This method blocks until the Handler returns an error or the provided context is cancelled.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
The Writer type is used to publish messages onto an event bus.
func NewWriter ¶
NewWriter returns a new instance of the Writer type that will publish events to the bus described in its URL string. See the gocloud.dev documentation for more information on provider specific urls.
func (*Writer) Check ¶ added in v0.9.0
Check returns the last non-nil error when trying to write an event. This method is used to implement the operation.Checker interface for use in health checks.
func (*Writer) Name ¶ added in v0.9.0
Name returns "event-writer" This method is used to implement the operation.Checker interface for use in health checks.