sqlstore

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: Apache-2.0 Imports: 17 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 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

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 New

func New(db *sql.DB, opts Options) *Store

func (*Store) AllAlertChannels

func (s *Store) AllAlertChannels(ctx context.Context) ([]store.AlertChannel, error)

func (*Store) AllQueueStats

func (s *Store) AllQueueStats(ctx context.Context, now time.Time) ([]store.QueueStatus, error)

func (*Store) AllScheduleStatus

func (s *Store) AllScheduleStatus(ctx context.Context) ([]store.ScheduleStatus, error)

func (*Store) CancelPendingTasks

func (s *Store) CancelPendingTasks(ctx context.Context, ws workspace.ID, queue string) (int, error)

func (*Store) CancelRun

func (s *Store) CancelRun(ctx context.Context, ws workspace.ID, id string) (store.Run, error)

func (*Store) CancelTask

func (s *Store) CancelTask(ctx context.Context, ws workspace.ID, id string) (store.Task, error)

func (*Store) CancelWorkflowRun added in v0.4.0

func (s *Store) CancelWorkflowRun(ctx context.Context, ws workspace.ID, id string) (store.WorkflowRun, error)

func (*Store) ClaimRuns

func (s *Store) ClaimRuns(ctx context.Context, limit int, now time.Time, grace time.Duration) ([]store.RunClaim, error)

func (*Store) ClaimTasks

func (s *Store) ClaimTasks(ctx context.Context, q store.Queue, limit int, now time.Time, grace time.Duration) ([]store.Task, error)

func (*Store) CloseGroup added in v0.2.0

func (s *Store) CloseGroup(ctx context.Context, ws workspace.ID, id string) (store.Group, error)

func (*Store) CreateAlertChannel

func (s *Store) CreateAlertChannel(ctx context.Context, ws workspace.ID, typ store.AlertChannelType, target string) (store.AlertChannel, error)

func (*Store) CreateGroup added in v0.2.0

func (s *Store) CreateGroup(ctx context.Context, ws workspace.ID, ng store.NewGroup) (store.Group, bool, error)

func (*Store) CreateTask

func (s *Store) CreateTask(ctx context.Context, ws workspace.ID, nt store.NewTask, autoCreateQueue bool) (store.Task, bool, error)

func (*Store) CreateTasks

func (s *Store) CreateTasks(ctx context.Context, ws workspace.ID, nts []store.NewTask, autoCreateQueue bool) ([]store.Task, []bool, error)

func (*Store) DeleteAlertChannel

func (s *Store) DeleteAlertChannel(ctx context.Context, ws workspace.ID, channelID string) error

func (*Store) DeleteFinishedGroups added in v0.2.0

func (s *Store) DeleteFinishedGroups(ctx context.Context, sw store.Sweep, limit int) (int, error)

func (*Store) DeleteFinishedRuns

func (s *Store) DeleteFinishedRuns(ctx context.Context, sw store.Sweep, limit int) (int, error)

func (*Store) DeleteFinishedTasks

func (s *Store) DeleteFinishedTasks(ctx context.Context, sw store.Sweep, limit int) (int, error)

func (*Store) DeleteFinishedWorkflowRuns added in v0.4.0

func (s *Store) DeleteFinishedWorkflowRuns(ctx context.Context, sw store.Sweep, limit int) (int, error)

func (*Store) DeleteQueue

func (s *Store) DeleteQueue(ctx context.Context, ws workspace.ID, name string) error

func (*Store) DeleteSchedule

func (s *Store) DeleteSchedule(ctx context.Context, ws workspace.ID, name string) error

func (*Store) DeleteWorkflow added in v0.4.0

func (s *Store) DeleteWorkflow(ctx context.Context, ws workspace.ID, name string) error

func (*Store) DeleteWorkspace added in v0.4.2

func (s *Store) DeleteWorkspace(ctx context.Context, id workspace.ID) error

DeleteWorkspace relies on every table cascading from workspaces, so a table added later goes with it without changes here.

func (*Store) DueQueues

func (s *Store) DueQueues(ctx context.Context, now time.Time) ([]store.Queue, error)

func (*Store) DueSchedules

func (s *Store) DueSchedules(ctx context.Context, now time.Time) ([]store.Schedule, error)

func (*Store) EnsureWorkspace

func (s *Store) EnsureWorkspace(ctx context.Context, id workspace.ID, name string) (store.Workspace, error)

func (*Store) ExpireWorkflowRuns added in v0.4.0

func (s *Store) ExpireWorkflowRuns(ctx context.Context, now time.Time, limit int) (int, error)

func (*Store) ExpiredLeases

func (s *Store) ExpiredLeases(ctx context.Context, now time.Time, limit int) ([]store.Task, error)

func (*Store) ExpiredRunLeases

func (s *Store) ExpiredRunLeases(ctx context.Context, now time.Time, limit int) ([]store.Run, error)

func (*Store) FailuresToAlert

func (s *Store) FailuresToAlert(ctx context.Context, ws workspace.ID, w store.AlertWindow) ([]store.AlertFailures, error)

func (*Store) FinishAttempt

func (s *Store) FinishAttempt(ctx context.Context, ws workspace.ID, r store.AttemptResult) (store.TaskState, error)

func (*Store) FinishAttempts

func (s *Store) FinishAttempts(ctx context.Context, rs []store.FinishedAttempt) ([]store.FinishOutcome, error)

func (*Store) FinishRunAttempt

func (s *Store) FinishRunAttempt(ctx context.Context, ws workspace.ID, r store.RunAttemptResult) (store.RunState, error)

func (*Store) FinishedActivity added in v0.4.0

func (s *Store) FinishedActivity(ctx context.Context, ws workspace.ID, since time.Time, bucket time.Duration) ([]store.FinishedCount, error)

func (*Store) FireSchedule

func (s *Store) FireSchedule(ctx context.Context, f store.Fire, now time.Time) (store.Run, bool, error)

func (*Store) GetAlertChannel

func (s *Store) GetAlertChannel(ctx context.Context, ws workspace.ID, channelID string) (store.AlertChannel, error)

func (*Store) GetGroup added in v0.2.0

func (s *Store) GetGroup(ctx context.Context, ws workspace.ID, id string) (store.Group, error)

func (*Store) GetQueue

func (s *Store) GetQueue(ctx context.Context, ws workspace.ID, name string) (store.Queue, error)

func (*Store) GetRun

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

func (*Store) GetSchedule

func (s *Store) GetSchedule(ctx context.Context, ws workspace.ID, name string) (store.Schedule, error)

func (*Store) GetTask

func (s *Store) GetTask(ctx context.Context, ws workspace.ID, id string) (store.Task, error)

func (*Store) GetWorkflow added in v0.4.0

func (s *Store) GetWorkflow(ctx context.Context, ws workspace.ID, name string) (store.Workflow, error)

func (*Store) GetWorkflowRun added in v0.4.0

func (s *Store) GetWorkflowRun(ctx context.Context, ws workspace.ID, id string) (store.WorkflowRun, error)

func (*Store) GetWorkspace

func (s *Store) GetWorkspace(ctx context.Context, id workspace.ID) (store.Workspace, error)

func (*Store) ListAlertChannels

func (s *Store) ListAlertChannels(ctx context.Context, ws workspace.ID) ([]store.AlertChannel, error)

func (*Store) ListAttempts

func (s *Store) ListAttempts(ctx context.Context, ws workspace.ID, taskID string) ([]store.Attempt, error)

func (*Store) ListGroups added in v0.2.0

func (s *Store) ListGroups(ctx context.Context, ws workspace.ID, f store.GroupFilter) ([]store.Group, string, error)

func (*Store) ListQueues

func (s *Store) ListQueues(ctx context.Context, ws workspace.ID) ([]store.Queue, error)

func (*Store) ListRunAttempts

func (s *Store) ListRunAttempts(ctx context.Context, ws workspace.ID, runID string) ([]store.Attempt, error)

func (*Store) ListRuns

func (s *Store) ListRuns(ctx context.Context, ws workspace.ID, f store.RunFilter) ([]store.Run, string, error)

func (*Store) ListSchedules

func (s *Store) ListSchedules(ctx context.Context, ws workspace.ID) ([]store.Schedule, error)

func (*Store) ListTasks

func (s *Store) ListTasks(ctx context.Context, ws workspace.ID, f store.TaskFilter) ([]store.Task, string, error)

func (*Store) ListWorkflowRuns added in v0.4.0

func (s *Store) ListWorkflowRuns(ctx context.Context, ws workspace.ID, f store.WorkflowRunFilter) ([]store.WorkflowRun, string, error)

func (*Store) ListWorkflows added in v0.4.0

func (s *Store) ListWorkflows(ctx context.Context, ws workspace.ID) ([]store.Workflow, error)

func (*Store) MarkAlerted

func (s *Store) MarkAlerted(ctx context.Context, ws workspace.ID, subjects []store.AlertSubject, at time.Time) error

func (*Store) NextRunAt

func (s *Store) NextRunAt(ctx context.Context, after time.Time) (time.Time, bool, error)

func (*Store) NextScheduleWork

func (s *Store) NextScheduleWork(ctx context.Context, after time.Time) (time.Time, bool, error)

func (*Store) PutQueue

func (s *Store) PutQueue(ctx context.Context, ws workspace.ID, name string, cfg store.QueueConfig) (store.Queue, bool, error)

func (*Store) PutSchedule

func (s *Store) PutSchedule(ctx context.Context, ws workspace.ID, name string, cfg store.ScheduleConfig, nextRunAt time.Time) (store.Schedule, bool, error)

func (*Store) PutWorkflow added in v0.4.0

func (s *Store) PutWorkflow(ctx context.Context, ws workspace.ID, name string, cfg store.WorkflowConfig) (store.Workflow, bool, error)

func (*Store) QueueActivity

func (s *Store) QueueActivity(ctx context.Context, ws workspace.ID, queue string, since time.Time) (store.QueueActivity, error)

func (*Store) QueueFailures

func (s *Store) QueueFailures(ctx context.Context, ws workspace.ID, queue string, limit int) ([]store.FailureGroup, error)

func (*Store) QueueStats

func (s *Store) QueueStats(ctx context.Context, ws workspace.ID, name string, now time.Time) (map[string]store.QueueStats, error)

func (*Store) RetryFailedTasks

func (s *Store) RetryFailedTasks(ctx context.Context, ws workspace.ID, queue, lastError string) (int, error)

func (*Store) RetryRun

func (s *Store) RetryRun(ctx context.Context, ws workspace.ID, id string) (store.Run, error)

func (*Store) RetryTask

func (s *Store) RetryTask(ctx context.Context, ws workspace.ID, id string) (store.Task, error)

func (*Store) RetryWorkflowRun added in v0.4.0

func (s *Store) RetryWorkflowRun(ctx context.Context, ws workspace.ID, id string, now time.Time) (store.WorkflowRun, error)

func (*Store) SetQueuePaused

func (s *Store) SetQueuePaused(ctx context.Context, ws workspace.ID, name string, paused bool) (store.Queue, error)

func (*Store) SetSchedulePaused

func (s *Store) SetSchedulePaused(ctx context.Context, ws workspace.ID, name string, paused bool, nextRunAt time.Time) (store.Schedule, error)

func (*Store) StartWorkflowRun added in v0.4.0

func (s *Store) StartWorkflowRun(ctx context.Context, ws workspace.ID, name string, nr store.NewWorkflowRun, now time.Time) (store.WorkflowRun, bool, error)

func (*Store) TaskActivity

func (s *Store) TaskActivity(ctx context.Context, ws workspace.ID, since time.Time, bucket time.Duration) ([]store.ActivityCount, error)

func (*Store) TriggerSchedule

func (s *Store) TriggerSchedule(ctx context.Context, ws workspace.ID, name string, now time.Time) (store.Run, error)

Jump to

Keyboard shortcuts

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