Help us shape the future of Go! Take the 2026 Go Developer Survey

history

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package history keeps every inspection, comparison, patch and migration sqlglot runs, with its result, in a local SQLite file, so a past run can be reviewed with every database it touched offline. It is also clicky's durable task RunStore, so a run's task progress and logs outlive the process.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("history record not found")

ErrNotFound is returned by Get for an id that was never recorded.

Functions

func DefaultPath

func DefaultPath() string

DefaultPath is $XDG_DATA_HOME/sqlglot-go/history.db.

func Redact

func Redact(dsn string) string

Redact is the form of a connection that may be recorded: a connection:// reference or a SQLite file path whole, a URL DSN without its password or query, and nothing of a keyword DSN, whose credentials cannot be told apart from the rest.

Types

type Filter

type Filter struct {
	Kind       Kind
	Connection string
	Limit      int
}

Filter narrows a listing; Connection matches either side.

type Kind

type Kind string
const (
	KindInspection Kind = "inspection"
	KindComparison Kind = "comparison"
	KindPatch      Kind = "patch"
	KindMigration  Kind = "migration"
)

type Record

type Record struct {
	ID        string          `json:"id"`
	Kind      Kind            `json:"kind"`
	Parent    string          `json:"parent,omitempty"`
	Dialect   string          `json:"dialect,omitempty"`
	Reference string          `json:"reference,omitempty"`
	Target    string          `json:"target,omitempty"`
	Schemas   []string        `json:"schemas"`
	Status    Status          `json:"status"`
	Error     string          `json:"error,omitempty"`
	CreatedAt time.Time       `json:"createdAt"`
	Summary   map[string]int  `json:"summary"`
	Payload   json.RawMessage `json:"payload,omitempty"`
}

Record is one finished run and its result. Its ID is the run's clicky group id, which also keys the run's task snapshots. An inspection that belongs to a comparison names it as Parent; Reference is empty for a single connection.

func (*Record) Complete

func (r *Record) Complete(value any, err error) error

Complete sets the record's status from err, and its payload from value; a failed run keeps a value too, such as a migration's partial result.

type Status

type Status string
const (
	StatusSucceeded Status = "succeeded"
	StatusFailed    Status = "failed"
)

type Store

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

func Open

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

Open creates the history file and its tables when missing. The CLI and the ui server may write it at once, hence WAL and a busy timeout.

func (*Store) Claim

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

func (*Store) Close

func (s *Store) Close() error

func (*Store) Control

func (s *Store) Control(_ context.Context, id string, action clickytask.ControlAction) error

Control refuses: a stored run has finished and has no live owner to drive.

func (*Store) Get

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

Get returns one record with its payload.

func (*Store) Has

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

func (*Store) List

func (s *Store) List(ctx context.Context, filter Filter) ([]Record, error)

List returns matching records newest first, without their payloads.

func (*Store) Runs

func (s *Store) Runs(ctx context.Context, filter clickytask.RunFilter) (_ []clickytask.RunMeta, returnErr error)

Runs lists stored runs matching filter, newest first.

func (*Store) Save

func (s *Store) Save(ctx context.Context, r Record) error

Save records a finished run, with its connections redacted. A run is recorded once: a second record with the same id is refused.

func (*Store) SaveRun

func (s *Store) SaveRun(ctx context.Context, groupID string, snapshots []clickytask.TaskSnapshot) error

SaveRun upserts a run's snapshots keyed by its clicky group id; clicky writes a run when it finishes and again when it is evicted, and the newest wins.

func (*Store) Snapshot

func (s *Store) Snapshot(ctx context.Context, id string) ([]clickytask.TaskSnapshot, error)

Snapshot returns a stored run's snapshots, or none for an unknown id.

Jump to

Keyboard shortcuts

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