store

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package store provides SQLite-backed persistence for workflow run data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPath

func DefaultPath() (string, error)

DefaultPath returns the default database path (~/.cache/ci-snitch/data.db).

Types

type Store

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

Store persists and queries workflow run data in SQLite.

func Open

func Open(path string) (*Store, error)

Open opens or creates a SQLite database at the given path.

busy_timeout and foreign_keys are per-connection settings, and database/sql pools connections — a `PRAGMA` via db.Exec would bind to a single pooled connection while concurrent workflow hydration opens others without it (SQLITE_BUSY on parallel saves, unenforced foreign keys). DSN _pragma parameters make the driver apply them to every connection it opens. busy_timeout comes first so the journal_mode switch itself retries under contention; WAL allows concurrent reads during parallel workflow writes.

func (*Store) Close

func (s *Store) Close() error

Close closes the database connection.

func (*Store) IncompleteRunIDs

func (s *Store) IncompleteRunIDs() ([]int64, error)

IncompleteRunIDs returns IDs of runs that are not yet completed.

func (*Store) LoadRunDetail

func (s *Store) LoadRunDetail(runID int64) (*model.RunDetail, error)

LoadRunDetail loads a fully hydrated run detail from the store. A missing run is an error identifiable as sql.ErrNoRows.

func (*Store) LoadRunDetails

func (s *Store) LoadRunDetails(workflowID int64, since time.Time) ([]model.RunDetail, error)

LoadRunDetails loads all completed run details for a workflow since the given time.

func (*Store) LoadRunDetailsByIDs added in v0.26.0

func (s *Store) LoadRunDetailsByIDs(ids []int64) ([]model.RunDetail, error)

LoadRunDetailsByIDs hydrates the given runs in three queries per chunk (runs, jobs, steps) instead of 1 + N + N×jobs individual lookups — a 500-run cached scan previously issued ~1500 queries.

func (*Store) RunsSince

func (s *Store) RunsSince(workflowID int64, since time.Time) ([]model.WorkflowRun, error)

RunsSince returns completed runs for a workflow since the given time.

func (*Store) SaveRunDetail

func (s *Store) SaveRunDetail(d *model.RunDetail) error

SaveRunDetail persists a run and its jobs and steps. Uses INSERT OR REPLACE so re-fetched runs (e.g. previously in-progress) are updated.

func (*Store) SaveRunDetails

func (s *Store) SaveRunDetails(details []model.RunDetail) error

SaveRunDetails persists multiple run details in a single transaction with prepared statements for efficiency.

Jump to

Keyboard shortcuts

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