Documentation
¶
Overview ¶
Package store holds the shared in-memory state machine behind the memory and filesystem reference Repository implementations. It centralizes the contract logic (Rev CAS, Guards, uniqueness, atomic ChangeSet application, and ClaimNextProcess) so both implementations satisfy an identical contract and pass repository/repotest. The package is internal: the boundary genuinely spans two sibling packages, which is why it is a package rather than unexported helpers.
Index ¶
- type State
- func (s *State) After(cs agentkit.ChangeSet) (*State, error)
- func (s *State) ClaimNext(workerID string, leaseUntil, now time.Time) (*agentkit.Process, *State, error)
- func (s *State) FindByIdempotencyKey(key string) (*agentkit.Process, error)
- func (s *State) FindOpenBySubject(subject agentkit.SubjectRef) (*agentkit.Process, error)
- func (s *State) GetProcess(pid agentkit.ProcessID) (*agentkit.Process, error)
- func (s *State) ListAwaits(pid agentkit.ProcessID) []*agentkit.Await
- func (s *State) ListEvents(pid agentkit.ProcessID, q agentkit.EventQuery) ([]*agentkit.Event, error)
- func (s *State) Marshal() ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type State ¶
type State struct {
// contains filtered or unexported fields
}
State is an immutable-by-convention snapshot of the whole Repository. Writes never mutate an existing State: After and ClaimNext build and return a fresh State (copy-on-write on the touched keys), so the caller can persist it before swapping it in. Reads deep-copy on the way out so a caller mutating a returned value cannot reach into stored state.
func (*State) After ¶
After validates cs against the current state and, on success, returns a fresh next State with the ChangeSet applied (Processes' Rev +1'd, Awaits upserted, Events appended). On any precondition or uniqueness failure it returns ErrConflict and no State (the caller writes nothing).
func (*State) ClaimNext ¶
func (s *State) ClaimNext(workerID string, leaseUntil, now time.Time) (*agentkit.Process, *State, error)
ClaimNext atomically claims the runnable Process with the smallest CreatedAt. It returns a deep copy of the claimed Process and the next State to persist, or (nil, nil, nil) when there is no target.
func (*State) FindByIdempotencyKey ¶
FindByIdempotencyKey returns the Process with the given idempotency key, or ErrProcessNotFound.
func (*State) FindOpenBySubject ¶
FindOpenBySubject returns the open (pending/running/waiting) Process holding the subject, or ErrProcessNotFound.
func (*State) GetProcess ¶
GetProcess returns a deep copy of the Process, or ErrProcessNotFound.
func (*State) ListAwaits ¶
ListAwaits returns deep copies of all awaits of a Process.
func (*State) ListEvents ¶
func (s *State) ListEvents(pid agentkit.ProcessID, q agentkit.EventQuery) ([]*agentkit.Event, error)
ListEvents returns deep copies of a Process's events in append order, starting after the cursor and capped at limit. See the Repository contract for the cursor semantics; an unknown after is agentkit.ErrEventNotFound.