Pure move: one 624-line storecontract.go becomes storecontract.go (package doc + composed TaskStore), task.go, capture.go, binding.go, mapping.go, source.go, status.go, resource.go, credentials.go and errors.go. The package remains the single seam; no declaration changed (verified line-identical against HEAD). task check green.
91 lines
5.3 KiB
Go
91 lines
5.3 KiB
Go
package storecontract
|
|
|
|
import (
|
|
"errors"
|
|
)
|
|
|
|
// Sentinel errors, part of the wire contract: staterpc's
|
|
// mapError/unmapError match these by (code, canonical message) across the
|
|
// gRPC boundary, so their message strings are load-bearing and must never
|
|
// change.
|
|
var (
|
|
// ErrStaleTransition is returned when a task transition's expected
|
|
// from status does not match the task's current status.
|
|
ErrStaleTransition = errors.New("store: stale transition: task status does not match expected from status")
|
|
// ErrIllegalTransition is returned when the transition table does not allow
|
|
// the status pair.
|
|
ErrIllegalTransition = errors.New("store: illegal transition: status pair is not in the transition table")
|
|
// ErrInvalidStep is returned when a step-execution request names a kind the
|
|
// store does not record or a step whose identifying fields do not resolve.
|
|
// Distinct from the transition sentinels, which cover a row's state.
|
|
ErrInvalidStep = errors.New("store: invalid step execution request")
|
|
// ErrResumeIncomplete is returned when a retry resumes after a stage whose
|
|
// last run did not complete, so there are no results to start from.
|
|
ErrResumeIncomplete = errors.New("store: the step before the resume point did not complete in its last run")
|
|
// ErrBindingNotFound is returned when a binding ID does not exist.
|
|
ErrBindingNotFound = errors.New("store: binding not found")
|
|
// ErrBindingOverlap is returned when a binding's matcher overlaps an
|
|
// existing binding for the same source.
|
|
ErrBindingOverlap = errors.New("store: binding overlaps existing binding for source")
|
|
// ErrBindingTransition is returned when a binding state transition is
|
|
// rejected by the draft -> pending_approval -> armed machine.
|
|
ErrBindingTransition = errors.New("store: binding state transition rejected")
|
|
// ErrAlreadyDispatched is returned when a dispatch ledger already holds the
|
|
// key.
|
|
ErrAlreadyDispatched = errors.New("store: binding already dispatched for capture")
|
|
// ErrCallNotYours is returned when a workflow.call status read names a
|
|
// task that is not a callee of the calling task, or the caller itself
|
|
// does not exist: a caller reads only the tasks it started
|
|
ErrCallNotYours = errors.New("store: task is not a callee of the calling task")
|
|
// ErrCallCallerNotRunning is returned when a workflow.call enqueue names
|
|
// a caller that is not running: a stale retry, or a bug in the caller.
|
|
ErrCallCallerNotRunning = errors.New("store: workflow.call caller is not running")
|
|
// ErrCallDepthExceeded is returned when a workflow.call enqueue would
|
|
// pass workflow.MaxCallDepth. The engine refuses the same call first;
|
|
// the store re-checks because it owns the table.
|
|
ErrCallDepthExceeded = errors.New("store: workflow.call would pass the depth limit")
|
|
// ErrMappingNotFound is returned when a mapping ID does not exist.
|
|
ErrMappingNotFound = errors.New("store: mapping not found")
|
|
// ErrEventTypeNotFound is returned when an event type ID does not exist.
|
|
ErrEventTypeNotFound = errors.New("store: event type not found")
|
|
// ErrSourceNotFound is returned when a source path does not exist.
|
|
ErrSourceNotFound = errors.New("store: source not found")
|
|
// ErrSourceInUse is returned when deleting a source an armed binding
|
|
// fires on.
|
|
ErrSourceInUse = errors.New("store: source has an armed binding")
|
|
// ErrSourcePathTaken is returned when a new source's path is in use.
|
|
ErrSourcePathTaken = errors.New("store: source path already taken")
|
|
// ErrSourceSigningStale is returned when a signing write's expected
|
|
// from state does not match the stored one.
|
|
ErrSourceSigningStale = errors.New("store: source signing does not match expected state")
|
|
// ErrHarnessSecretNotFound is returned when no OAuth token set is
|
|
// stored for an org/service pair -- the setup terminal has not
|
|
// captured one yet.
|
|
ErrHarnessSecretNotFound = errors.New("store: harness secret not found")
|
|
// ErrRereviewCapReached is returned when a review gate re-review would
|
|
// round past prreview.MaxRereviewRounds. The task stays waiting and its
|
|
// gate row is unchanged. The dashboard answers it 409, like every other
|
|
// conflict.
|
|
ErrRereviewCapReached = errors.New("store: re-review cap reached")
|
|
|
|
// ErrResourceNotFound is returned when a control-plane resource kind has
|
|
// no stored document. It is in-process only (not on the gRPC wire): the
|
|
// control plane runs in the daemon against the local store.
|
|
ErrResourceNotFound = errors.New("resource not found")
|
|
// ErrResourceVersionConflict is returned when a resource write carries an
|
|
// expected version that does not match the stored revision.
|
|
ErrResourceVersionConflict = errors.New("resource version conflict")
|
|
)
|
|
|
|
// ErrUnavailable means the store could not serve a request now: it is
|
|
// restarting or unreachable. It is not paired with a canonical message the way
|
|
// the sentinels above are -- staterpc derives it from the Unavailable code
|
|
// alone, whose text varies by transport -- and it is the one store error a
|
|
// caller with budget may answer by retrying rather than by failing its own
|
|
// work. The wrapping keeps the gRPC status code readable through the chain.
|
|
var ErrUnavailable = errors.New("store: state store unavailable")
|
|
|
|
// ErrRunCredentialUnknown is a run credential that was never issued, was
|
|
// revoked, or has expired.
|
|
var ErrRunCredentialUnknown = errors.New("run credential unknown or expired")
|