Documentation
¶
Index ¶
- Constants
- func Known(eventType string) bool
- func RebuildViews(ctx context.Context, views []View) error
- func RecordEvent(ctx context.Context, j journal.Journal, views []View, event journal.Event) error
- func RecordEventAndLog(ctx context.Context, logger *zap.Logger, j journal.Journal, views []View, ...) error
- func RecordKeyPin(ctx context.Context, j journal.Journal, views []View, selfID uuid.UUID, ...) error
- func RecordNodeStarted(ctx context.Context, logger *zap.Logger, j journal.Journal, views []View, ...) error
- func ValidatePayload(eventType string, payload json.RawMessage) error
- type EventsByID
- func (e *EventsByID) Apply(ctx context.Context, event journal.Event) error
- func (e *EventsByID) Get(ctx context.Context, id uuid.UUID) (*journal.Event, error)
- func (e *EventsByID) List(ctx context.Context) ([]journal.Event, error)
- func (e *EventsByID) Rebuild(ctx context.Context, jr journalreader.Reader) error
- type EventsByNode
- func (e *EventsByNode) Apply(ctx context.Context, event journal.Event) error
- func (e *EventsByNode) Get(ctx context.Context, nodeID, id uuid.UUID) (*journal.Event, error)
- func (e *EventsByNode) List(ctx context.Context, nodeID uuid.UUID) ([]journal.Event, error)
- func (e *EventsByNode) Rebuild(ctx context.Context, jr journalreader.Reader) error
- type EventsByNodeKey
- type EventsByType
- func (e *EventsByType) Apply(ctx context.Context, event journal.Event) error
- func (e *EventsByType) Get(ctx context.Context, eventType string, id uuid.UUID) (*journal.Event, error)
- func (e *EventsByType) List(ctx context.Context, eventType string) ([]journal.Event, error)
- func (e *EventsByType) Rebuild(ctx context.Context, jr journalreader.Reader) error
- type EventsByTypeKey
- type KeyPin
- type NodeStarted
- type PeerEvent
- type PinnedKeys
- type View
- type Workloads
- func (e *Workloads) Apply(ctx context.Context, event journal.Event) error
- func (e *Workloads) Get(ctx context.Context, id uuid.UUID) (*workload.Spec, error)
- func (e *Workloads) List(ctx context.Context) ([]workload.Spec, error)
- func (e *Workloads) Rebuild(ctx context.Context, jr journalreader.Reader) error
Constants ¶
const ( // EventTypeWorkloadSpec is a workload desired-state copy: initial // assignment at epoch zero, or an orphan reassignment with the epoch // incremented. Payload: workload.Spec. EventTypeWorkloadSpec = "workload.spec" // EventTypeWorkloadUnhealthy is a signal-action sickness edge. // Payload: workload.Unhealthy. EventTypeWorkloadUnhealthy = "workload.unhealthy" // EventTypeWorkloadInstancePrefix prefixes per-instance lifecycle // events (workload.instance.running, workload.instance.stopped). // Payload: workload.Instance. EventTypeWorkloadInstancePrefix = "workload.instance." // EventTypeNodeStarted marks a daemon boot. Payload: NodeStarted. EventTypeNodeStarted = "node.started" // EventTypePeerSeen, EventTypePeerUpdated, EventTypePeerLost track // membership edges observed from memberlist. Payload: PeerEvent. EventTypePeerSeen = "peer.seen" EventTypePeerUpdated = "peer.updated" EventTypePeerLost = "peer.lost" // EventTypePeerKeyPinned pins a node's first-seen Noise identity. // Payload: KeyPin. EventTypePeerKeyPinned = "peer.keypinned" )
Journal event types. Every type the fleet writes is named here; no producer or view may use a bare type string. Unknown types (a newer binary's events replayed on an older one) are always recordable and never interpretable: the journal keeps their bytes, typed views skip them. Validation is shape, not completeness: missing fields decode to zero values, so additive payload evolution never breaks old readers.
Variables ¶
This section is empty.
Functions ¶
func Known ¶
Known reports whether the type is a catalogued event type. The workload instance family matches by prefix; everything else by exact type.
func RebuildViews ¶
RebuildViews reconstructs each view from the journal using a fresh reader per view.
func RecordEvent ¶
RecordEvent appends an event to the journal and applies it to every configured view. Known-type payloads are shape-checked first so producer bugs fail loudly at write time instead of diverging views silently. Unknown types always record: the journal is a complete log regardless of reader version, and typed views skip what they do not know.
func RecordEventAndLog ¶
func RecordEventAndLog( ctx context.Context, logger *zap.Logger, j journal.Journal, views []View, event journal.Event, message string, fields ...zap.Field, ) error
RecordEventAndLog appends an event, applies it to views, and logs the persisted event.
func RecordKeyPin ¶
func RecordKeyPin(ctx context.Context, j journal.Journal, views []View, selfID uuid.UUID, pin KeyPin) error
RecordKeyPin appends a peer.keypinned event and applies it to views.
func RecordNodeStarted ¶
func RecordNodeStarted( ctx context.Context, logger *zap.Logger, j journal.Journal, views []View, nodeID uuid.UUID, memberlistAddress netip.AddrPort, ) error
RecordNodeStarted creates a node.started event and persists it.
func ValidatePayload ¶
func ValidatePayload(eventType string, payload json.RawMessage) error
ValidatePayload checks a payload against its type's shape by decoding into the payload struct. Unknown types always validate: recordability must never depend on the reader's version. Malformed JSON fails for every type, including unknown ones.
Types ¶
type EventsByID ¶
type EventsByID struct {
// contains filtered or unexported fields
}
EventsByID maintains a view of journal events indexed by event ID in key-value storage.
func NewEventsByID ¶
func NewEventsByID(kv *kvstore.KVStore) *EventsByID
NewEventsByID creates a new EventsByID view backed by the given KVStore.
func (*EventsByID) Apply ¶
Apply updates the view by storing the given journal event indexed by its ID.
func (*EventsByID) Rebuild ¶
func (e *EventsByID) Rebuild(ctx context.Context, jr journalreader.Reader) error
Rebuild reconstructs the EventsByID view by resetting the storage bucket and replaying all journal events.
type EventsByNode ¶
type EventsByNode struct {
// contains filtered or unexported fields
}
EventsByNode maintains a view of journal events indexed by node ID and event ID in key-value storage.
func NewEventsByNode ¶
func NewEventsByNode(kv *kvstore.KVStore) *EventsByNode
NewEventsByNode creates a new EventsByNode view backed by the given KVStore.
func (*EventsByNode) Apply ¶
Apply updates the view by storing the given journal event indexed by its NodeID and ID.
func (*EventsByNode) Get ¶
Get retrieves a single journal event for a specific node ID and event ID.
func (*EventsByNode) Rebuild ¶
func (e *EventsByNode) Rebuild(ctx context.Context, jr journalreader.Reader) error
Rebuild reconstructs the EventsByNode view by resetting the storage bucket and replaying all journal events.
type EventsByNodeKey ¶
EventsByNodeKey represents the lookup key for an event associated with a node.
type EventsByType ¶
type EventsByType struct {
// contains filtered or unexported fields
}
EventsByType maintains a view of journal events indexed by event type and event ID in key-value storage.
func NewEventsByType ¶
func NewEventsByType(kv *kvstore.KVStore) *EventsByType
NewEventsByType creates a new EventsByType view backed by the given KVStore.
func (*EventsByType) Apply ¶
Apply updates the view by storing the given journal event indexed by its Type and ID.
func (*EventsByType) Get ¶
func (e *EventsByType) Get(ctx context.Context, eventType string, id uuid.UUID) (*journal.Event, error)
Get retrieves a single journal event matching the specified event type and ID.
func (*EventsByType) Rebuild ¶
func (e *EventsByType) Rebuild(ctx context.Context, jr journalreader.Reader) error
Rebuild reconstructs the EventsByType view by resetting the storage bucket and replaying all journal events.
type EventsByTypeKey ¶
EventsByTypeKey represents the lookup key for an event associated with an event type.
type KeyPin ¶
type KeyPin struct {
NodeID uuid.UUID `json:"node_id"`
PublicKey []byte `json:"public_key"`
Generation uint64 `json:"generation"`
}
KeyPin is one pinned Noise identity: the peer's node ID, static public key, and the rotation generation the key was seen at.
type NodeStarted ¶
type NodeStarted struct {
MemberlistAddress string `json:"memberlist_address"`
}
NodeStarted is the payload of a node.started event.
type PeerEvent ¶
type PeerEvent struct {
PeerID uuid.UUID `json:"peer_id"`
Address string `json:"address"`
State string `json:"state"`
}
PeerEvent is the payload of peer membership edge events. Address and State stay strings so producers convert once at the edge; the catalog never imports peer packages back.
type PinnedKeys ¶
type PinnedKeys struct {
// contains filtered or unexported fields
}
PinnedKeys maintains first-seen Noise identities keyed by node ID.
func NewPinnedKeys ¶
func NewPinnedKeys(kv *kvstore.KVStore) *PinnedKeys
NewPinnedKeys creates a new PinnedKeys view backed by the given KVStore.
func (*PinnedKeys) Apply ¶
Apply records the pin carried by a peer.keypinned event, ignoring every other event type.
func (*PinnedKeys) Rebuild ¶
func (v *PinnedKeys) Rebuild(ctx context.Context, jr journalreader.Reader) error
Rebuild reconstructs the PinnedKeys view by resetting the storage bucket and replaying all peer.keypinned journal events in order.
type View ¶
type View interface {
// Apply processes a single event to keep the view up to date.
Apply(ctx context.Context, event journal.Event) error
// Rebuild reconstructs the entire view by replaying the journal from scratch.
Rebuild(ctx context.Context, jr journalreader.Reader) error
}
View represents a read-optimised projection of journal events. Views are kept in sync by applying events as they are appended to the journal.
type Workloads ¶
type Workloads struct {
// contains filtered or unexported fields
}
Workloads maintains a view of workload specs derived from workload.spec journal events.
func NewWorkloads ¶
NewWorkloads creates a new Workloads view backed by the given KVStore.
func (*Workloads) Apply ¶
Apply updates the view if the event is a workload.spec event, storing or updating the workload spec.