Documentation
¶
Overview ¶
Package sqlstore holds the SQL shared by the postgres and sqlite stores.
Queries are written once with ? placeholders and portable SQL. The dialect differences are small: placeholder syntax, how timestamps are stored (TIMESTAMPTZ vs Unix milliseconds), row locking and wake-up notifications. The postgres and sqlite packages embed Store and add what is truly database-specific (migrations, leader election).
Index ¶
- type Options
- type Store
- func (s *Store) AllAlertChannels(ctx context.Context) ([]store.AlertChannel, error)
- func (s *Store) AllQueueStats(ctx context.Context, now time.Time) ([]store.QueueStatus, error)
- func (s *Store) AllScheduleStatus(ctx context.Context) ([]store.ScheduleStatus, error)
- func (s *Store) CancelPendingTasks(ctx context.Context, ws workspace.ID, queue string) (int, error)
- func (s *Store) CancelRun(ctx context.Context, ws workspace.ID, id string) (store.Run, error)
- func (s *Store) CancelTask(ctx context.Context, ws workspace.ID, id string) (store.Task, error)
- func (s *Store) CancelWorkflowRun(ctx context.Context, ws workspace.ID, id string) (store.WorkflowRun, error)
- func (s *Store) ClaimRuns(ctx context.Context, limit int, now time.Time, grace time.Duration) ([]store.RunClaim, error)
- func (s *Store) ClaimTasks(ctx context.Context, q store.Queue, limit int, now time.Time, ...) ([]store.Task, error)
- func (s *Store) CloseGroup(ctx context.Context, ws workspace.ID, id string) (store.Group, error)
- func (s *Store) CreateAlertChannel(ctx context.Context, ws workspace.ID, typ store.AlertChannelType, ...) (store.AlertChannel, error)
- func (s *Store) CreateGroup(ctx context.Context, ws workspace.ID, ng store.NewGroup) (store.Group, bool, error)
- func (s *Store) CreateTask(ctx context.Context, ws workspace.ID, nt store.NewTask, autoCreateQueue bool) (store.Task, bool, error)
- func (s *Store) CreateTasks(ctx context.Context, ws workspace.ID, nts []store.NewTask, ...) ([]store.Task, []bool, error)
- func (s *Store) DeleteAlertChannel(ctx context.Context, ws workspace.ID, channelID string) error
- func (s *Store) DeleteFinishedGroups(ctx context.Context, sw store.Sweep, limit int) (int, error)
- func (s *Store) DeleteFinishedRuns(ctx context.Context, sw store.Sweep, limit int) (int, error)
- func (s *Store) DeleteFinishedTasks(ctx context.Context, sw store.Sweep, limit int) (int, error)
- func (s *Store) DeleteFinishedWorkflowRuns(ctx context.Context, sw store.Sweep, limit int) (int, error)
- func (s *Store) DeleteQueue(ctx context.Context, ws workspace.ID, name string) error
- func (s *Store) DeleteSchedule(ctx context.Context, ws workspace.ID, name string) error
- func (s *Store) DeleteWorkflow(ctx context.Context, ws workspace.ID, name string) error
- func (s *Store) DeleteWorkspace(ctx context.Context, id workspace.ID) error
- func (s *Store) DueQueues(ctx context.Context, now time.Time) ([]store.Queue, error)
- func (s *Store) DueSchedules(ctx context.Context, now time.Time) ([]store.Schedule, error)
- func (s *Store) EnsureWorkspace(ctx context.Context, id workspace.ID, name string) (store.Workspace, error)
- func (s *Store) ExpireWorkflowRuns(ctx context.Context, now time.Time, limit int) (int, error)
- func (s *Store) ExpiredLeases(ctx context.Context, now time.Time, limit int) ([]store.Task, error)
- func (s *Store) ExpiredRunLeases(ctx context.Context, now time.Time, limit int) ([]store.Run, error)
- func (s *Store) FailuresToAlert(ctx context.Context, ws workspace.ID, w store.AlertWindow) ([]store.AlertFailures, error)
- func (s *Store) FinishAttempt(ctx context.Context, ws workspace.ID, r store.AttemptResult) (store.TaskState, error)
- func (s *Store) FinishAttempts(ctx context.Context, rs []store.FinishedAttempt) ([]store.FinishOutcome, error)
- func (s *Store) FinishRunAttempt(ctx context.Context, ws workspace.ID, r store.RunAttemptResult) (store.RunState, error)
- func (s *Store) FinishedActivity(ctx context.Context, ws workspace.ID, since time.Time, bucket time.Duration) ([]store.FinishedCount, error)
- func (s *Store) FireSchedule(ctx context.Context, f store.Fire, now time.Time) (store.Run, bool, error)
- func (s *Store) GetAlertChannel(ctx context.Context, ws workspace.ID, channelID string) (store.AlertChannel, error)
- func (s *Store) GetGroup(ctx context.Context, ws workspace.ID, id string) (store.Group, error)
- func (s *Store) GetQueue(ctx context.Context, ws workspace.ID, name string) (store.Queue, error)
- func (s *Store) GetRun(ctx context.Context, ws workspace.ID, id string) (store.Run, error)
- func (s *Store) GetSchedule(ctx context.Context, ws workspace.ID, name string) (store.Schedule, error)
- func (s *Store) GetTask(ctx context.Context, ws workspace.ID, id string) (store.Task, error)
- func (s *Store) GetWorkflow(ctx context.Context, ws workspace.ID, name string) (store.Workflow, error)
- func (s *Store) GetWorkflowRun(ctx context.Context, ws workspace.ID, id string) (store.WorkflowRun, error)
- func (s *Store) GetWorkspace(ctx context.Context, id workspace.ID) (store.Workspace, error)
- func (s *Store) ListAlertChannels(ctx context.Context, ws workspace.ID) ([]store.AlertChannel, error)
- func (s *Store) ListAttempts(ctx context.Context, ws workspace.ID, taskID string) ([]store.Attempt, error)
- func (s *Store) ListGroups(ctx context.Context, ws workspace.ID, f store.GroupFilter) ([]store.Group, string, error)
- func (s *Store) ListQueues(ctx context.Context, ws workspace.ID) ([]store.Queue, error)
- func (s *Store) ListRunAttempts(ctx context.Context, ws workspace.ID, runID string) ([]store.Attempt, error)
- func (s *Store) ListRuns(ctx context.Context, ws workspace.ID, f store.RunFilter) ([]store.Run, string, error)
- func (s *Store) ListSchedules(ctx context.Context, ws workspace.ID) ([]store.Schedule, error)
- func (s *Store) ListTasks(ctx context.Context, ws workspace.ID, f store.TaskFilter) ([]store.Task, string, error)
- func (s *Store) ListWorkflowRuns(ctx context.Context, ws workspace.ID, f store.WorkflowRunFilter) ([]store.WorkflowRun, string, error)
- func (s *Store) ListWorkflows(ctx context.Context, ws workspace.ID) ([]store.Workflow, error)
- func (s *Store) MarkAlerted(ctx context.Context, ws workspace.ID, subjects []store.AlertSubject, ...) error
- func (s *Store) NextRunAt(ctx context.Context, after time.Time) (time.Time, bool, error)
- func (s *Store) NextScheduleWork(ctx context.Context, after time.Time) (time.Time, bool, error)
- func (s *Store) PutQueue(ctx context.Context, ws workspace.ID, name string, cfg store.QueueConfig) (store.Queue, bool, error)
- func (s *Store) PutSchedule(ctx context.Context, ws workspace.ID, name string, cfg store.ScheduleConfig, ...) (store.Schedule, bool, error)
- func (s *Store) PutWorkflow(ctx context.Context, ws workspace.ID, name string, cfg store.WorkflowConfig) (store.Workflow, bool, error)
- func (s *Store) QueueActivity(ctx context.Context, ws workspace.ID, queue string, since time.Time) (store.QueueActivity, error)
- func (s *Store) QueueFailures(ctx context.Context, ws workspace.ID, queue string, limit int) ([]store.FailureGroup, error)
- func (s *Store) QueueStats(ctx context.Context, ws workspace.ID, name string, now time.Time) (map[string]store.QueueStats, error)
- func (s *Store) RetryFailedTasks(ctx context.Context, ws workspace.ID, queue, lastError string) (int, error)
- func (s *Store) RetryRun(ctx context.Context, ws workspace.ID, id string) (store.Run, error)
- func (s *Store) RetryTask(ctx context.Context, ws workspace.ID, id string) (store.Task, error)
- func (s *Store) RetryWorkflowRun(ctx context.Context, ws workspace.ID, id string, now time.Time) (store.WorkflowRun, error)
- func (s *Store) SetQueuePaused(ctx context.Context, ws workspace.ID, name string, paused bool) (store.Queue, error)
- func (s *Store) SetSchedulePaused(ctx context.Context, ws workspace.ID, name string, paused bool, ...) (store.Schedule, error)
- func (s *Store) StartWorkflowRun(ctx context.Context, ws workspace.ID, name string, nr store.NewWorkflowRun, ...) (store.WorkflowRun, bool, error)
- func (s *Store) TaskActivity(ctx context.Context, ws workspace.ID, since time.Time, bucket time.Duration) ([]store.ActivityCount, error)
- func (s *Store) TriggerSchedule(ctx context.Context, ws workspace.ID, name string, now time.Time) (store.Run, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
// Postgres selects $n placeholders, TIMESTAMPTZ values and row locking.
// Otherwise the SQLite dialect is used.
Postgres bool
// Notify is called after a commit that may have made tasks due sooner:
// an enqueue, a retry, a resumed queue or new limits. It wakes the
// dispatcher, which may run in another process.
Notify func()
}
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) AllAlertChannels ¶
func (*Store) AllQueueStats ¶
func (*Store) AllScheduleStatus ¶
func (*Store) CancelPendingTasks ¶
func (*Store) CancelTask ¶
func (*Store) CancelWorkflowRun ¶ added in v0.4.0
func (*Store) ClaimTasks ¶
func (*Store) CloseGroup ¶ added in v0.2.0
func (*Store) CreateAlertChannel ¶
func (*Store) CreateGroup ¶ added in v0.2.0
func (*Store) CreateTask ¶
func (*Store) CreateTasks ¶
func (*Store) DeleteAlertChannel ¶
func (*Store) DeleteFinishedGroups ¶ added in v0.2.0
func (*Store) DeleteFinishedRuns ¶
func (*Store) DeleteFinishedTasks ¶
func (*Store) DeleteFinishedWorkflowRuns ¶ added in v0.4.0
func (*Store) DeleteQueue ¶
func (*Store) DeleteSchedule ¶
func (*Store) DeleteWorkflow ¶ added in v0.4.0
func (*Store) DeleteWorkspace ¶ added in v0.4.2
DeleteWorkspace relies on every table cascading from workspaces, so a table added later goes with it without changes here.
func (*Store) DueSchedules ¶
func (*Store) EnsureWorkspace ¶
func (*Store) ExpireWorkflowRuns ¶ added in v0.4.0
func (*Store) ExpiredLeases ¶
func (*Store) ExpiredRunLeases ¶
func (*Store) FailuresToAlert ¶
func (s *Store) FailuresToAlert(ctx context.Context, ws workspace.ID, w store.AlertWindow) ([]store.AlertFailures, error)
func (*Store) FinishAttempt ¶
func (*Store) FinishAttempts ¶
func (s *Store) FinishAttempts(ctx context.Context, rs []store.FinishedAttempt) ([]store.FinishOutcome, error)