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 ¶
- Variables
- func DefaultPath() string
- func Redact(dsn string) string
- type Filter
- type Kind
- type Record
- type Status
- type Store
- func (s *Store) Claim(ctx context.Context, id string) error
- func (s *Store) Close() error
- func (s *Store) Control(_ context.Context, id string, action clickytask.ControlAction) error
- func (s *Store) Get(ctx context.Context, id string) (Record, error)
- func (s *Store) Has(ctx context.Context, id string) (bool, error)
- func (s *Store) List(ctx context.Context, filter Filter) ([]Record, error)
- func (s *Store) Runs(ctx context.Context, filter clickytask.RunFilter) (_ []clickytask.RunMeta, returnErr error)
- func (s *Store) Save(ctx context.Context, r Record) error
- func (s *Store) SaveRun(ctx context.Context, groupID string, snapshots []clickytask.TaskSnapshot) error
- func (s *Store) Snapshot(ctx context.Context, id string) ([]clickytask.TaskSnapshot, error)
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("history record not found")
ErrNotFound is returned by Get for an id that was never recorded.
Functions ¶
Types ¶
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.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func Open ¶
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) 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) 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 ¶
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.