package storecontract import ( "context" "time" "github.com/samcharles93/archie-core/internal/domain/health" ) // ConfigSnapshotStore holds the published configuration view. type ConfigSnapshotStore interface { PutConfigSnapshot(ctx context.Context, snapshot ConfigSnapshot) error ConfigSnapshot(ctx context.Context) (ConfigSnapshot, bool, error) } // ChannelStatusStore holds channel runtime state published by the process // hosting the channels. type ChannelStatusStore interface { // PutChannelStatus records the reporting process's whole set: a channel it no // longer reports is removed rather than left behind, because a stale "running" // row is a lie the dashboard would show indefinitely. PutChannelStatus(ctx context.Context, channels []ChannelStatus) error ChannelStatus(ctx context.Context) ([]ChannelStatus, error) } // ApplyStatusStore holds which version of each control-plane resource each // process is running. Same split as ConfigSnapshotStore and for the same // reason: the writers are the processes that apply a resource, the reader is // the UI, and a task-scoped credential must reach neither. type ApplyStatusStore interface { PutApplyStatus(ctx context.Context, status ApplyStatus) error ListApplyStatus(ctx context.Context) ([]ApplyStatus, error) } // PresenceStore holds one record per running service instance. Writers are // the services themselves; readers are the UI and archied status. type PresenceStore interface { PutPresence(ctx context.Context, presence Presence) error ListPresence(ctx context.Context) ([]Presence, error) } // ConfigSnapshot is the published, secret-free configuration view. Schema // names Document's shape. type ConfigSnapshot struct { Schema string Document []byte PublishedAt time.Time } // ChannelStatus is one channel's runtime state as the process hosting it // reports it. ReloadSupported is a capability declaration rather than a request: // asking for a reload travels on its own surface, because a transient request and // a durable state do not share a lifetime. type ChannelStatus struct { ID string Name string State string Detail string Configured bool ReloadSupported bool ObservedAt time.Time } // ApplyStatus is one process's report on one resource kind. On error, // AppliedVersion stays at the last applied version. ReportedAt is // re-stamped periodically. type ApplyStatus struct { Process string `json:"process"` Kind string `json:"kind"` AppliedVersion int64 `json:"applied_version"` Error string `json:"error,omitempty"` ReportedAt time.Time `json:"reported_at"` } // Presence is one running service instance. Ready and Detail summarise its // readiness probes; Detail names the degraded ones. type Presence struct { Checks []health.Component `json:"checks"` Service string `json:"service"` InstanceID string `json:"instance_id"` Version string `json:"version"` InstallType string `json:"install_type"` StartedAt time.Time `json:"started_at"` ReportedAt time.Time `json:"reported_at"` Ready bool `json:"ready"` Detail string `json:"detail,omitempty"` }