store

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package store owns the SQLite ledger and its migrations.

Index

Constants

This section is empty.

Variables

View Source
var ErrRunNotFound = errors.New("run not found")

Functions

func Terminal

func Terminal(state string) bool

Types

type ImmediateTx

type ImmediateTx struct {
	// contains filtered or unexported fields
}

ImmediateTx exposes queries on the connection holding the write reservation. The connection and any rows must not escape the callback.

func (*ImmediateTx) Exec

func (tx *ImmediateTx) Exec(ctx context.Context, query string, args ...any) (int64, error)

type JobState

type JobState struct {
	Fired       bool       `json:"-"`
	ScheduleKey string     `json:"-"`
	Name        string     `json:"name"`
	Paused      bool       `json:"paused"`
	Approved    bool       `json:"approved"`
	NextFire    *time.Time `json:"next_fire"`
	LastRunID   string     `json:"last_run_id"`
	UpdatedAt   time.Time  `json:"updated_at"`
	AnchorAt    time.Time  `json:"anchor_at"`
	Orphaned    bool       `json:"orphaned"`
}

type Run

type Run struct {
	ID           string     `json:"id"`
	Job          string     `json:"job"`
	Trigger      string     `json:"trigger"`
	ScheduledFor time.Time  `json:"scheduled_for"`
	State        string     `json:"state"`
	PID          *int       `json:"pid"`
	OwnerStart   *time.Time `json:"owner_start"`
	OwnerPID     *int       `json:"owner_pid"`
	ProcStart    *time.Time `json:"proc_start"`
	ExitCode     *int       `json:"exit_code"`
	StartedAt    *time.Time `json:"started_at"`
	EndedAt      *time.Time `json:"ended_at"`
	Worktree     string     `json:"worktree"`
	Kept         bool       `json:"kept"`
	Error        string     `json:"error"`
}

func NewRun

func NewRun(job, trigger string, at time.Time) (Run, error)

type Store

type Store struct {
	// contains filtered or unexported fields
}

func Open

func Open(ctx context.Context, path string) (*Store, error)

Open creates or opens the ledger and applies migrations atomically.

func OpenExisting

func OpenExisting(ctx context.Context, path string) (*Store, error)

OpenExisting inspects an existing ledger without creating or migrating it.

func (*Store) AdvanceCursor

func (s *Store) AdvanceCursor(ctx context.Context, st JobState) error

func (*Store) CheckIdentity

func (s *Store) CheckIdentity() error

CheckIdentity rejects an unlinked or replaced ledger before another scheduling pass.

func (*Store) ClaimOwned

func (s *Store) ClaimOwned(ctx context.Context, id string, at time.Time, ownerStart time.Time) error

func (*Store) ClaimRun

func (s *Store) ClaimRun(ctx context.Context, id string) error

func (*Store) ClearKept

func (s *Store) ClearKept(ctx context.Context, id string) error

func (*Store) Close

func (s *Store) Close() error

func (*Store) CreateRun

func (s *Store) CreateRun(ctx context.Context, r Run) error

func (*Store) DeleteTerminal

func (s *Store) DeleteTerminal(ctx context.Context, id string) (bool, error)

func (*Store) EnqueueFire

func (s *Store) EnqueueFire(ctx context.Context, r Run) (Run, bool, error)

EnqueueFire reports actual insertion and retries primary-key collisions only.

func (*Store) FinishClaimedRun

func (s *Store) FinishClaimedRun(ctx context.Context, r Run) error

func (*Store) FinishRun

func (s *Store) FinishRun(ctx context.Context, r Run) error

func (*Store) GetRun

func (s *Store) GetRun(ctx context.Context, id string) (Run, error)

func (*Store) JobStates

func (s *Store) JobStates(ctx context.Context) (map[string]JobState, error)

func (*Store) ListRuns

func (s *Store) ListRuns(ctx context.Context, job, state string, limit int) ([]Run, error)

func (*Store) MemoryNote

func (s *Store) MemoryNote(ctx context.Context, job string) (string, error)

func (*Store) PreviousRun

func (s *Store) PreviousRun(ctx context.Context, r Run) (*Run, error)

PreviousRun finds terminal history independently of enqueue order.

func (*Store) PutJobState

func (s *Store) PutJobState(ctx context.Context, st JobState) error

func (*Store) SchemaVersion

func (s *Store) SchemaVersion(ctx context.Context) (int, error)

func (*Store) SetDaemonStopped

func (s *Store) SetDaemonStopped(ctx context.Context, id string) error

func (*Store) SetMemoryNote

func (s *Store) SetMemoryNote(ctx context.Context, job, note string) error

func (*Store) StartOwnedRun

func (s *Store) StartOwnedRun(ctx context.Context, r Run) error

func (*Store) StartRun

func (s *Store) StartRun(ctx context.Context, id string, pid int, at time.Time, worktree string) error

func (*Store) SyncDefinition

func (s *Store) SyncDefinition(ctx context.Context, st JobState) error

SyncDefinition preserves a cursor advanced concurrently by the scheduler.

func (*Store) Unknown

func (s *Store) Unknown(ctx context.Context, r Run) error

func (*Store) WithImmediateTx

func (s *Store) WithImmediateTx(ctx context.Context, fn func(*ImmediateTx) error) error

WithImmediateTx reserves the writer before invoking fn, even before its first write.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL