Documentation
¶
Overview ¶
Package events is the fleet's one typed event schema — a generic Envelope wrapping a typed payload — so no event-consuming tool hand-rolls a bespoke JSON event model with ad-hoc reconnect/filter logic. The Envelope is the transport-independent shape; payloads are typed and registered by event type.
It is a pure, generic event-schema primitive: it models any event source (an Event Center, a message bus, a webhook) and never names or imports any particular project.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Envelope ¶
type Envelope struct {
// ID is a unique event id (idempotency key for at-least-once delivery).
ID string `json:"id"`
// Type selects the payload shape.
Type Type `json:"type"`
// Source names the emitter (a URL/hostname/logical name).
Source string `json:"source"`
// Time is when the event occurred (UTC).
Time time.Time `json:"time"`
// Data is the typed payload, carried as raw JSON.
Data json.RawMessage `json:"data"`
}
Envelope is the generic, transport-independent event wrapper. It carries metadata (id, type, source, time) plus the typed payload as raw JSON so it can be decoded into the registered concrete payload type.
func New ¶
New builds an Envelope around a typed payload. The Envelope's Type is derived from the payload (payload.EventType), and Data is the payload marshalled to JSON. A nil payload, or a JSON-unmarshalable payload, yields a typed error.
func Parse ¶
Parse decodes raw bytes into an Envelope (without decoding the payload). Use Decode to obtain the typed payload.
type Payload ¶
type Payload interface {
// EventType returns the Type this payload is the body of.
EventType() Type
}
Payload is the marker interface every typed event payload satisfies. A payload reports the Type it belongs to so an Envelope can be built and validated from the payload alone.
type SecretEvent ¶
type SecretEvent struct {
// Kind is the specific secret event type (created/updated/deleted).
Kind Type `json:"kind"`
// Path is the logical secret path the event concerns.
Path string `json:"path"`
// Version is the new version after the change, if known.
Version int `json:"version,omitempty"`
// Tags are arbitrary labels attached to the secret.
Tags []string `json:"tags,omitempty"`
}
SecretEvent is the typed payload for the secret.* event types — the generic shape a secret-lifecycle source emits. It carries no vendor-specific fields.
func (SecretEvent) EventType ¶
func (e SecretEvent) EventType() Type
EventType returns the secret event's Kind, satisfying Payload.
type Type ¶
type Type string
Type identifies the kind of event an Envelope carries; it selects the payload shape. New types are additive.
const ( // SecretCreated signals a new secret was created at Payload.Path. SecretCreated Type = "secret.created" // SecretUpdated signals a secret's value rotated/changed at Payload.Path. SecretUpdated Type = "secret.updated" // SecretDeleted signals a secret was removed at Payload.Path. SecretDeleted Type = "secret.deleted" )
Built-in event types. Consumers may register their own via Register.