archie-core-8cda.6.8's carrier. The service now records channel lifecycle and has nowhere to put it: /api/channels answered with nothing because webui.Server.Channels had no production source, and reload answered 501 for the same reason. This adds the surface the register decided on, following the split archie-core-ymut established for config snapshots -- a pair of administrative RPCs whose writer is one process and whose reader is the UI -- and wires both ends. Wire and store: PutChannelStatus / ListChannelStatus, with ChannelStatus carrying id, name, state, detail, configured, reload_supported and observed_at. The store holds one row per channel and replaces the reported set, so a channel the reporter no longer mentions is deleted rather than left standing as a stale "running"; an empty report clears the table, because hosting no channels is a fact worth reporting. A row without an id is refused: it could never be replaced or removed by a later report. Writer: the service publishes on every lifecycle transition through a coalescing signal -- a burst of transitions is one write, since a reader only wants the latest state of every channel -- plus a start-up report and a final report after shutdown, so a stopped service leaves the store honest. A failed write is logged and retried on the next signal; the dashboard losing channel state is worth a warning and never worth failing a channel start over. Reader: webui.Server.Channels becomes a source rather than a concrete manager, and webui.RemoteChannelStatus reads the store the way RemoteConfigView reads the config snapshot. A store it cannot reach reports nothing rather than a stale "running", and a state the reader does not recognise is carried through rather than dropped. The contract's own index gains the group in the same change that adds the RPCs -- a surface the grouped table does not list is one nobody finds -- and the count moves to 51. The register records why the surface is the State Store rather than a resource kind, and why reload gets its own surface rather than a field here: reading status must not be able to retrigger an action, a transient request is not distinguishable from state once anything polls it, and it would invert the writer/reader relationship the precedent establishes. Verified: task check exit 0. New coverage: the store's replace-the-set semantics and its refusal of an id-less row, the reader's mapping including an unknown state, and the publisher's start-up, transition and final reports.
82 lines
3.3 KiB
Go
82 lines
3.3 KiB
Go
// Package store defines the task and event persistence for archied's data.
|
|
// TaskStore is the full surface the daemon needs and *Store is its SQLite
|
|
// implementation.
|
|
//
|
|
// REVISED (archie-core-8cda.5.6): the producer-owned contract surfaces this
|
|
// package used to define live in internal/contracts/store/v1 (package
|
|
// storev1) -- the approved contract location -- so the archie-ui process can
|
|
// reference the contract without linking this SQLite implementation. The
|
|
// definitions below are type aliases for compatibility with the daemon-side
|
|
// callers; new UI-process-facing code imports storev1 directly.
|
|
package store
|
|
|
|
import (
|
|
"github.com/samcharles93/archie-core/internal/domain/storecontract"
|
|
"github.com/samcharles93/archie-core/internal/domain/workflow"
|
|
)
|
|
|
|
// Aliases: the daemon/webui/intake store surfaces moved to storecontract. The
|
|
// message strings of the sentinel errors are the wire contract (see
|
|
// storev1's var block); the aliases change nothing observable.
|
|
type (
|
|
TaskStore = storecontract.TaskStore
|
|
TaskLifecycle = storecontract.TaskLifecycle
|
|
TaskArchiver = storecontract.TaskArchiver
|
|
TaskRetryer = storecontract.TaskRetryer
|
|
TaskQueries = storecontract.TaskQueries
|
|
TaskEvents = storecontract.TaskEvents
|
|
TaskLogStore = storecontract.TaskLogStore
|
|
CaptureStore = storecontract.CaptureStore
|
|
ConfigSnapshotStore = storecontract.ConfigSnapshotStore
|
|
ChannelStatusStore = storecontract.ChannelStatusStore
|
|
ApplyStatusStore = storecontract.ApplyStatusStore
|
|
MappingStore = storecontract.MappingStore
|
|
BindingStore = storecontract.BindingStore
|
|
BindingDispatcher = storecontract.BindingDispatcher
|
|
BindingTaskCreator = storecontract.BindingTaskCreator
|
|
PlaybookDispatcher = storecontract.PlaybookDispatcher
|
|
CapturedEvent = storecontract.CapturedEvent
|
|
ConfigSnapshot = storecontract.ConfigSnapshot
|
|
ChannelStatus = storecontract.ChannelStatus
|
|
ApplyStatus = storecontract.ApplyStatus
|
|
WorkflowStat = storecontract.WorkflowStat
|
|
StageStat = storecontract.StageStat
|
|
DayTokens = storecontract.DayTokens
|
|
)
|
|
|
|
var (
|
|
ErrStaleTransition = storecontract.ErrStaleTransition
|
|
ErrBindingNotFound = storecontract.ErrBindingNotFound
|
|
ErrBindingOverlap = storecontract.ErrBindingOverlap
|
|
ErrBindingTransition = storecontract.ErrBindingTransition
|
|
ErrAlreadyDispatched = storecontract.ErrAlreadyDispatched
|
|
ErrMappingNotFound = storecontract.ErrMappingNotFound
|
|
)
|
|
|
|
// Compile-time check: *Store satisfies TaskStore.
|
|
var _ TaskStore = (*Store)(nil)
|
|
|
|
// Compile-time check: *Store satisfies ChannelStatusStore.
|
|
var _ ChannelStatusStore = (*Store)(nil)
|
|
|
|
// Compile-time check: *Store satisfies workflow.Store.
|
|
var _ workflow.Store = (*Store)(nil)
|
|
|
|
// Compile-time check: *Store satisfies CaptureStore.
|
|
var _ CaptureStore = (*Store)(nil)
|
|
|
|
// Compile-time check: *Store satisfies MappingStore.
|
|
var _ MappingStore = (*Store)(nil)
|
|
|
|
// Compile-time check: *Store satisfies BindingStore.
|
|
var _ BindingStore = (*Store)(nil)
|
|
|
|
// Compile-time check: *Store satisfies BindingDispatcher.
|
|
var _ BindingDispatcher = (*Store)(nil)
|
|
|
|
// Compile-time check: *Store satisfies BindingTaskCreator.
|
|
var _ BindingTaskCreator = (*Store)(nil)
|
|
|
|
// Compile-time check: *Store satisfies PlaybookDispatcher.
|
|
var _ PlaybookDispatcher = (*Store)(nil)
|