Documentation
¶
Overview ¶
Package state persists Baselines, Candidates, and coordination state in SQLite. Go schema versions migrate in place; Python databases are unsupported.
Index ¶
- Variables
- func IsBusy(err error) bool
- type AcceptedDigest
- type Attempt
- type AuditFilter
- type CandidateObservation
- type CandidateRecord
- type Evaluation
- type Key
- type NotifierHealth
- type PendingProposal
- type ProposalRecord
- type SchedulerProgress
- type StackCheck
- type Status
- type Store
- func (s *Store) AcceptPendingProposal(token string, key Key, expected PendingProposal, now time.Time) (bool, error)
- func (s *Store) AcceptedDigest(key Key) (string, bool, error)
- func (s *Store) AcquireLease(now time.Time, ttlSeconds int) (string, bool, error)
- func (s *Store) ActiveTransaction() (*TransactionProgress, error)
- func (s *Store) Attempts(limit int) ([]Attempt, error)
- func (s *Store) AuditPage(filter AuditFilter) ([]Attempt, error)
- func (s *Store) BeginTransaction(token string, key Key, runID string, now time.Time) error
- func (s *Store) Candidate(key Key) (*CandidateRecord, error)
- func (s *Store) Candidates() ([]CandidateRecord, error)
- func (s *Store) CheckLease(token string, now time.Time) error
- func (s *Store) ClearBreaker(reason string, now time.Time) error
- func (s *Store) ClearPendingProposal(key Key) (bool, error)
- func (s *Store) ClearSuppression(event, stack, service string) error
- func (s *Store) Close() error
- func (s *Store) CompleteTransaction(token string, attempt Attempt, acceptedDigest, breakerReason string, ...) error
- func (s *Store) Evaluations() ([]Evaluation, error)
- func (s *Store) FinishStackCheck(token string, key Key, runID, outcome string, now time.Time) error
- func (s *Store) FinishTransaction(token string) error
- func (s *Store) LastAttempt(key Key) (*Attempt, error)
- func (s *Store) NotifierDestination() (string, error)
- func (s *Store) NotifierHealth() (NotifierHealth, error)
- func (s *Store) ObserveCandidate(key Key, digest string, now time.Time) (CandidateObservation, error)
- func (s *Store) OpenBreaker(reason string, now time.Time) error
- func (s *Store) PendingProposal(key Key) (*PendingProposal, error)
- func (s *Store) ReconcileTransaction(token string, attempt Attempt, reason string, now time.Time) error
- func (s *Store) RecordAttempt(attempt Attempt, now time.Time) error
- func (s *Store) RecordEvaluation(token string, key Key, runID string, result domain.ResultCode, detail string, ...) error
- func (s *Store) RecordNotifierFailure() error
- func (s *Store) RecordNotifierSuccess(now time.Time) error
- func (s *Store) ReleaseLease(token string) error
- func (s *Store) RenewLease(token string, now time.Time, ttlSeconds int) error
- func (s *Store) ResetSuppression() error
- func (s *Store) Scheduler() (SchedulerProgress, error)
- func (s *Store) SetAcceptedDigest(key Key, digest string, now time.Time) error
- func (s *Store) SetNotifierDestination(fingerprint string) error
- func (s *Store) SetPendingProposal(key Key, digest, proposalURL string, now time.Time) error
- func (s *Store) SetSchedulerProgress(token string, p SchedulerProgress, now time.Time) error
- func (s *Store) SetSuppressionState(event, stack, service, state string, now time.Time) error
- func (s *Store) SetTransactionPhase(token, phase string, now time.Time) error
- func (s *Store) StackChecks() ([]StackCheck, error)
- func (s *Store) StartStackCheck(token string, key Key, runID string, now time.Time) error
- func (s *Store) Status(now time.Time) (Status, error)
- func (s *Store) SuppressionState(event, stack, service string) (string, bool, error)
- func (s *Store) WithLease(token string, clock func() time.Time) *Store
- type TransactionProgress
Constants ¶
This section is empty.
Variables ¶
var ErrLeaseLost = errors.New("the run lease is no longer owned")
ErrLeaseLost indicates missing, expired, or superseded ownership.
Functions ¶
Types ¶
type AcceptedDigest ¶
AcceptedDigest pairs a Key with its accepted Baseline digest.
type Attempt ¶
type Attempt struct {
// ID is the audit trail's own order. It is the cursor `ripen audit`
// pages by, and it never appears in the JSON surface.
ID int64
Key Key
RunID string
Actor domain.Actor
OldDigest string
NewDigest string
Result domain.ResultCode
Detail string
AttemptedAt time.Time
}
Attempt is one recorded Transaction attempt.
type AuditFilter ¶
type AuditFilter struct {
Limit int
Cursor int64
RunID string
Backend domain.Backend
Stack string
Service string
Result domain.ResultCode
}
AuditFilter narrows and pages the audit trail. Every field is optional; an empty filter reads the newest attempts.
type CandidateObservation ¶
CandidateObservation is one observed Candidate digest and its history.
type CandidateRecord ¶
type CandidateRecord struct {
Key Key
Digest string
FirstSeen time.Time
LastSeen time.Time
Count int
}
CandidateRecord is one observed Candidate, with its Key.
type Evaluation ¶ added in v1.2.0
type Evaluation struct {
Key Key
RunID string
Result domain.ResultCode
Detail string
EvaluatedAt time.Time
}
Evaluation records an outcome independently of Candidate history.
type Key ¶
Key identifies one Service's state: backend, stack, and service, with service empty for a stack-level policy. The Python schema's state_key column pretended this was one string; schema v1 stores the three parts.
type NotifierHealth ¶
NotifierHealth is the persisted Notifier delivery health.
type PendingProposal ¶
PendingProposal is an open Proposal (PR) awaiting review.
type ProposalRecord ¶
ProposalRecord pairs a Key with its pending Proposal for Status.
type SchedulerProgress ¶ added in v1.2.0
SchedulerProgress records scheduled and completed observation times.
type StackCheck ¶ added in v1.2.0
type StackCheck struct {
OwnerToken string
Key Key
RunID string
StartedAt time.Time
CompletedAt *time.Time
Outcome string
}
StackCheck records the most recent observation attempt for a stack.
type Status ¶
type Status struct {
BreakerOpen bool
BreakerReason string
AcceptedDigests []AcceptedDigest
LeaseActive bool
PendingProposals []ProposalRecord
}
Status is the durable state snapshot behind `ripen status`.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the SQLite-backed state store.
func Open ¶
Open opens (creating if needed) the state database at path, creating the parent directory when missing.
func (*Store) AcceptPendingProposal ¶ added in v1.2.0
func (s *Store) AcceptPendingProposal(token string, key Key, expected PendingProposal, now time.Time) (bool, error)
AcceptPendingProposal accepts only the exact Proposal that was evaluated.
func (*Store) AcceptedDigest ¶
AcceptedDigest returns the accepted Baseline digest for a Key.
func (*Store) AcquireLease ¶
AcquireLease takes the run lease when no unexpired lease exists, returning an owner token. BEGIN IMMEDIATE serializes contenders.
func (*Store) ActiveTransaction ¶ added in v1.2.0
func (s *Store) ActiveTransaction() (*TransactionProgress, error)
ActiveTransaction returns the unfinished Transaction, even after lease expiry.
func (*Store) AuditPage ¶
func (s *Store) AuditPage(filter AuditFilter) ([]Attempt, error)
AuditPage reads the audit trail newest first, narrowed by the filter and paged by attempt id. The audit trail is the attempts table — never the Event stream, which is a notification channel and not a record.
func (*Store) BeginTransaction ¶ added in v1.2.0
BeginTransaction reserves deployment ownership while the breaker is closed.
func (*Store) Candidate ¶
func (s *Store) Candidate(key Key) (*CandidateRecord, error)
Candidate returns one Key's observed Candidate, or nil.
func (*Store) Candidates ¶
func (s *Store) Candidates() ([]CandidateRecord, error)
Candidates returns every observed Candidate, oldest Key first.
func (*Store) CheckLease ¶ added in v1.2.0
CheckLease verifies that the token still owns an unexpired lease.
func (*Store) ClearBreaker ¶
ClearBreaker closes the Circuit breaker; the operator's reason is mandatory and recorded.
func (*Store) ClearPendingProposal ¶
ClearPendingProposal removes a Key's Proposal record, reporting whether one existed.
func (*Store) ClearSuppression ¶
ClearSuppression drops one suppression key, re-arming it. Recovery uses this: a stack that failed, recovered, and fails again must page the second time.
func (*Store) CompleteTransaction ¶ added in v1.2.0
func (s *Store) CompleteTransaction(token string, attempt Attempt, acceptedDigest, breakerReason string, clearMarker bool, now time.Time) error
CompleteTransaction atomically records the owner's outcome and any terminal state changes.
func (*Store) Evaluations ¶ added in v1.2.0
func (s *Store) Evaluations() ([]Evaluation, error)
Evaluations returns latest service evaluations.
func (*Store) FinishStackCheck ¶ added in v1.2.0
FinishStackCheck persists an observation's terminal outcome.
func (*Store) FinishTransaction ¶ added in v1.2.0
FinishTransaction removes only the matching owner's completed Transaction.
func (*Store) LastAttempt ¶
LastAttempt returns the newest audit entry for one Key, or nil. The Key is matched exactly, empty service included, which is why this does not go through the audit filter.
func (*Store) NotifierDestination ¶
NotifierDestination reads the fingerprint of the destination the suppression table was built against.
func (*Store) NotifierHealth ¶
func (s *Store) NotifierHealth() (NotifierHealth, error)
NotifierHealth reads the persisted Notifier delivery health.
func (*Store) ObserveCandidate ¶
func (s *Store) ObserveCandidate(key Key, digest string, now time.Time) (CandidateObservation, error)
ObserveCandidate records one observation of a Candidate digest. A new digest replaces any previous Candidate for the Key; re-observing the same digest increments its count, preserving first_seen.
func (*Store) OpenBreaker ¶
OpenBreaker opens the Circuit breaker with a reason.
func (*Store) PendingProposal ¶
func (s *Store) PendingProposal(key Key) (*PendingProposal, error)
PendingProposal returns the Key's open Proposal, or nil.
func (*Store) ReconcileTransaction ¶ added in v1.2.0
func (s *Store) ReconcileTransaction(token string, attempt Attempt, reason string, now time.Time) error
ReconcileTransaction records an explicitly verified interrupted Transaction and clears its breaker atomically.
func (*Store) RecordAttempt ¶
RecordAttempt appends one Transaction attempt to the audit trail.
func (*Store) RecordEvaluation ¶ added in v1.2.0
func (s *Store) RecordEvaluation(token string, key Key, runID string, result domain.ResultCode, detail string, now time.Time) error
RecordEvaluation persists the latest service check, including refusals.
func (*Store) RecordNotifierFailure ¶
RecordNotifierFailure increments the persisted failure streak.
func (*Store) RecordNotifierSuccess ¶
RecordNotifierSuccess records a successful delivery, resetting the failure streak.
func (*Store) ReleaseLease ¶
ReleaseLease releases the lease if the token still owns it; releasing a superseded token is a no-op.
func (*Store) RenewLease ¶ added in v1.2.0
RenewLease extends an unexpired lease only for its current owner.
func (*Store) ResetSuppression ¶
ResetSuppression clears every suppression record — used when the webhook destination changes, so the new destination pages current state once (which is correct).
func (*Store) Scheduler ¶ added in v1.2.0
func (s *Store) Scheduler() (SchedulerProgress, error)
Scheduler returns durable scheduling timestamps.
func (*Store) SetAcceptedDigest ¶
SetAcceptedDigest records a digest as the accepted Baseline and clears the Key's Candidates and pending Proposal: accepting is the terminal state of both.
func (*Store) SetNotifierDestination ¶
SetNotifierDestination records which destination the suppression table belongs to.
func (*Store) SetPendingProposal ¶
SetPendingProposal records an open Proposal for a Key.
func (*Store) SetSchedulerProgress ¶ added in v1.2.0
SetSchedulerProgress persists the next tick and last completed observation.
func (*Store) SetSuppressionState ¶
SetSuppressionState records the state a notification was last sent for.
func (*Store) SetTransactionPhase ¶ added in v1.2.0
SetTransactionPhase persists the owner's current Transaction phase.
func (*Store) StackChecks ¶ added in v1.2.0
func (s *Store) StackChecks() ([]StackCheck, error)
StackChecks returns latest stack observation progress.
func (*Store) StartStackCheck ¶ added in v1.2.0
StartStackCheck persists an observation start before work is dispatched.
func (*Store) SuppressionState ¶
SuppressionState reads the last notified state for a suppression key.