Documentation
¶
Overview ¶
Package state stores Ramen resources, revisions, runs, events, locks, and audit records in a local SQLite database.
The state package is part of Ramen's supported v0.1 core API.
Index ¶
- Constants
- func DefaultPath(configDir string) string
- func Init(ctx context.Context, path string) error
- func Restore(ctx context.Context, statePath, fromPath string, force bool) error
- func WorkspacePath(configDir, workspace string) (string, error)
- type AsyncEvidenceFilter
- type AsyncEvidenceRecord
- type AuditDocument
- type ExportDocument
- type Lock
- type LockHeldError
- type LockHolderMismatchError
- type LockNotFoundError
- type LockOptions
- type MigrationRecord
- type ResourceSnapshot
- type Revision
- type Run
- type RunEvent
- type Store
- func (s *Store) AcquireLock(ctx context.Context, name, holder string, ttl time.Duration) error
- func (s *Store) AcquireLockWithOptions(ctx context.Context, opts LockOptions) error
- func (s *Store) AttachLockRun(ctx context.Context, name, holder string, runID int64) error
- func (s *Store) Audit(ctx context.Context) (AuditDocument, error)
- func (s *Store) Backup(ctx context.Context, outPath string) error
- func (s *Store) CheckIntegrity(ctx context.Context) error
- func (s *Store) Close() error
- func (s *Store) CurrentLock(ctx context.Context, name string) (*Lock, error)
- func (s *Store) CurrentResource(ctx context.Context, address string) (*ResourceSnapshot, error)
- func (s *Store) DeleteResource(ctx context.Context, address string) error
- func (s *Store) Export(ctx context.Context) (ExportDocument, error)
- func (s *Store) FinishRun(ctx context.Context, id int64, status, summaryJSON string) error
- func (s *Store) ForceUnlock(ctx context.Context, name, holder string) (*Lock, error)
- func (s *Store) ListAsyncEvidence(ctx context.Context, filter AsyncEvidenceFilter) ([]AsyncEvidenceRecord, error)
- func (s *Store) ListCurrentResources(ctx context.Context) ([]ResourceSnapshot, error)
- func (s *Store) ListLocks(ctx context.Context) ([]Lock, error)
- func (s *Store) ListMigrationRecords(ctx context.Context) ([]MigrationRecord, error)
- func (s *Store) ListRevisions(ctx context.Context, address string) ([]Revision, error)
- func (s *Store) ListRunEvents(ctx context.Context, runID int64) ([]RunEvent, error)
- func (s *Store) ListRuns(ctx context.Context, status string) ([]Run, error)
- func (s *Store) MarkAbandonedRuns(ctx context.Context, olderThan time.Duration) ([]Run, error)
- func (s *Store) Migrate(ctx context.Context) error
- func (s *Store) RecordAsyncEvidence(ctx context.Context, record AsyncEvidenceRecord) error
- func (s *Store) RecordResource(ctx context.Context, snap ResourceSnapshot) error
- func (s *Store) RecordRevision(ctx context.Context, rev Revision) error
- func (s *Store) RecordRunEvent(ctx context.Context, event RunEvent) error
- func (s *Store) ReleaseLock(ctx context.Context, name, holder string) error
- func (s *Store) RenewLock(ctx context.Context, name, holder string, ttl time.Duration) error
- func (s *Store) SchemaReady(ctx context.Context) error
- func (s *Store) StartLockRenewal(ctx context.Context, name, holder string, ttl, interval time.Duration) func()
- func (s *Store) StartRun(ctx context.Context, command string) (int64, error)
- func (s *Store) Vacuum(ctx context.Context) error
- func (s *Store) WithTx(ctx context.Context, fn func(*Tx) error) error
- type Tx
- func (tx *Tx) CurrentResource(ctx context.Context, address string) (*ResourceSnapshot, error)
- func (tx *Tx) DeleteResource(ctx context.Context, address string) error
- func (tx *Tx) RecordResource(ctx context.Context, snap ResourceSnapshot) error
- func (tx *Tx) RecordRevision(ctx context.Context, rev Revision) error
Constants ¶
View Source
const ( ExportVersion = "ramen.state.export.v1" AuditVersion = "ramen.audit.v1" )
View Source
const SchemaVersion = 4
Variables ¶
This section is empty.
Functions ¶
func DefaultPath ¶
func WorkspacePath ¶
Types ¶
type AsyncEvidenceFilter ¶
type AsyncEvidenceRecord ¶
type AsyncEvidenceRecord struct {
ID int64 `json:"id,omitempty"`
RunID int64 `json:"run_id,omitempty"`
ResourceAddress string `json:"resource_address,omitempty"`
Action string `json:"action,omitempty"`
OperationID string `json:"operation_id,omitempty"`
RecordKind string `json:"record_kind"`
Phase string `json:"phase,omitempty"`
EvidenceID string `json:"evidence_id"`
AttemptID string `json:"attempt_id,omitempty"`
RequestEvidenceID string `json:"request_evidence_id,omitempty"`
Sequence int64 `json:"sequence,omitempty"`
RecordJSON string `json:"record_json"`
CreatedAt time.Time `json:"created_at,omitempty"`
}
type AuditDocument ¶
type AuditDocument struct {
Version string `json:"version"`
SchemaVersion int `json:"schemaVersion"`
ExportedAt time.Time `json:"exportedAt"`
Digest string `json:"digest"`
Counts map[string]int `json:"counts"`
Migrations []MigrationRecord `json:"migrations,omitempty"`
Runs []Run `json:"runs,omitempty"`
RunEvents []RunEvent `json:"run_events,omitempty"`
AsyncEvidence []AsyncEvidenceRecord `json:"async_evidence,omitempty"`
Locks []Lock `json:"locks,omitempty"`
}
type ExportDocument ¶
type ExportDocument struct {
Version string `json:"version"`
SchemaVersion int `json:"schemaVersion"`
ExportedAt time.Time `json:"exportedAt"`
Migrations []MigrationRecord `json:"migrations"`
Resources []ResourceSnapshot `json:"resources"`
Revisions []Revision `json:"revisions"`
Runs []Run `json:"runs"`
RunEvents []RunEvent `json:"run_events,omitempty"`
AsyncEvidence []AsyncEvidenceRecord `json:"async_evidence,omitempty"`
Locks []Lock `json:"locks"`
}
type LockHeldError ¶
type LockHeldError struct {
Name string
Holder string
Host string
PID int
RunID int64
AcquiredAt time.Time
ExpiresAt time.Time
HeartbeatAt time.Time
}
func (LockHeldError) Error ¶
func (e LockHeldError) Error() string
type LockHolderMismatchError ¶
type LockHolderMismatchError struct {
Name string
Holder string
Expected string
Host string
PID int
RunID int64
AcquiredAt time.Time
ExpiresAt time.Time
HeartbeatAt time.Time
}
func (LockHolderMismatchError) Error ¶
func (e LockHolderMismatchError) Error() string
type LockNotFoundError ¶
type LockNotFoundError struct {
Name string
}
func (LockNotFoundError) Error ¶
func (e LockNotFoundError) Error() string
type LockOptions ¶
type MigrationRecord ¶
type ResourceSnapshot ¶
type RunEvent ¶
type RunEvent struct {
ID int64 `json:"id,omitempty"`
RunID int64 `json:"run_id,omitempty"`
ResourceAddress string `json:"resource_address,omitempty"`
Action string `json:"action,omitempty"`
OperationID string `json:"operation_id,omitempty"`
Phase string `json:"phase"`
Message string `json:"message,omitempty"`
MetadataJSON string `json:"metadata_json,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
}
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) AcquireLock ¶
func (*Store) AcquireLockWithOptions ¶
func (s *Store) AcquireLockWithOptions(ctx context.Context, opts LockOptions) error
func (*Store) AttachLockRun ¶
func (*Store) CurrentLock ¶
func (*Store) CurrentResource ¶
func (*Store) DeleteResource ¶
func (*Store) ForceUnlock ¶
func (*Store) ListAsyncEvidence ¶
func (s *Store) ListAsyncEvidence(ctx context.Context, filter AsyncEvidenceFilter) ([]AsyncEvidenceRecord, error)
func (*Store) ListCurrentResources ¶
func (s *Store) ListCurrentResources(ctx context.Context) ([]ResourceSnapshot, error)
func (*Store) ListMigrationRecords ¶
func (s *Store) ListMigrationRecords(ctx context.Context) ([]MigrationRecord, error)
func (*Store) ListRevisions ¶
func (*Store) ListRunEvents ¶
func (*Store) MarkAbandonedRuns ¶
func (*Store) RecordAsyncEvidence ¶
func (s *Store) RecordAsyncEvidence(ctx context.Context, record AsyncEvidenceRecord) error
func (*Store) RecordResource ¶
func (s *Store) RecordResource(ctx context.Context, snap ResourceSnapshot) error
func (*Store) RecordRevision ¶
func (*Store) RecordRunEvent ¶
func (*Store) ReleaseLock ¶
func (*Store) StartLockRenewal ¶
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
func (*Tx) CurrentResource ¶
func (*Tx) RecordResource ¶
func (tx *Tx) RecordResource(ctx context.Context, snap ResourceSnapshot) error
Click to show internal directories.
Click to hide internal directories.