{"modulePath":"github.com/worklydev/workly","version":"v0.5.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package sqlstore\n\nPackage sqlstore holds the SQL shared by the postgres and sqlite stores.\n\nQueries 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).\n\n## Types\n\n```go\ntype Options struct {\n\t// Postgres selects $n placeholders, TIMESTAMPTZ values and row locking.\n\t// Otherwise the SQLite dialect is used.\n\tPostgres bool\n\t// Notify is called after a commit that may have made tasks due sooner:\n\t// an enqueue, a retry, a resumed queue or new limits. It wakes the\n\t// dispatcher, which may run in another process.\n\tNotify func()\n}\n```\n\n```go\ntype Store struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc New(db *sql.DB, opts Options) *Store\n```\n\n```go\nfunc (s *Store) AllAlertChannels(ctx context.Context) ([]store.AlertChannel, error)\n```\n\n```go\nfunc (s *Store) AllQueueStats(ctx context.Context, now time.Time) ([]store.QueueStatus, error)\n```\n\n```go\nfunc (s *Store) AllScheduleStatus(ctx context.Context) ([]store.ScheduleStatus, error)\n```\n\n```go\nfunc (s *Store) AutoPauseQueue(ctx context.Context, ws workspace.ID, name, errMsg string, now, nextProbe time.Time) (bool, error)\n```\n\n```go\nfunc (s *Store) AutoResumeQueue(ctx context.Context, ws workspace.ID, name string) (*store.AutoPause, error)\n```\n\n```go\nfunc (s *Store) CancelPendingTasks(ctx context.Context, ws workspace.ID, queue string) (int, error)\n```\n\n```go\nfunc (s *Store) CancelRun(ctx context.Context, ws workspace.ID, id string) (store.Run, error)\n```\n\n```go\nfunc (s *Store) CancelTask(ctx context.Context, ws workspace.ID, id string) (store.Task, error)\n```\n\n```go\nfunc (s *Store) CancelWorkflowRun(ctx context.Context, ws workspace.ID, id string) (store.WorkflowRun, error)\n```\n\n```go\nfunc (s *Store) ClaimProbe(ctx context.Context, q store.Queue, now time.Time, grace time.Duration) ([]store.Task, error)\n```\n\n```go\nfunc (s *Store) ClaimRuns(ctx context.Context, limit int, now time.Time, grace time.Duration) ([]store.RunClaim, error)\n```\n\n```go\nfunc (s *Store) ClaimTasks(ctx context.Context, q store.Queue, limit int, now time.Time, grace time.Duration) ([]store.Task, error)\n```\n\n```go\nfunc (s *Store) CloseGroup(ctx context.Context, ws workspace.ID, id string) (store.Group, error)\n```\n\n```go\nfunc (s *Store) CreateAlertChannel(ctx context.Context, ws workspace.ID, typ store.AlertChannelType, target string) (store.AlertChannel, error)\n```\n\n```go\nfunc (s *Store) CreateGroup(ctx context.Context, ws workspace.ID, ng store.NewGroup) (store.Group, bool, error)\n```\n\n```go\nfunc (s *Store) CreateTask(ctx context.Context, ws workspace.ID, nt store.NewTask, autoCreateQueue bool) (store.Task, bool, error)\n```\n\n```go\nfunc (s *Store) CreateTasks(ctx context.Context, ws workspace.ID, nts []store.NewTask, autoCreateQueue bool) ([]store.Task, []bool, error)\n```\n\n```go\nfunc (s *Store) DeleteAlertChannel(ctx context.Context, ws workspace.ID, channelID string) error\n```\n\n```go\nfunc (s *Store) DeleteFinishedGroups(ctx context.Context, sw store.Sweep, limit int) (int, error)\n```\n\n```go\nfunc (s *Store) DeleteFinishedRuns(ctx context.Context, sw store.Sweep, limit int) (int, error)\n```\n\n```go\nfunc (s *Store) DeleteFinishedTasks(ctx context.Context, sw store.Sweep, limit int) (int, error)\n```\n\n```go\nfunc (s *Store) DeleteFinishedWorkflowRuns(ctx context.Context, sw store.Sweep, limit int) (int, error)\n```\n\n```go\nfunc (s *Store) DeleteQueue(ctx context.Context, ws workspace.ID, name string) error\n```\n\n```go\nfunc (s *Store) DeleteSchedule(ctx context.Context, ws workspace.ID, name string) error\n```\n\n```go\nfunc (s *Store) DeleteWorkflow(ctx context.Context, ws workspace.ID, name string) error\n```\n\n```go\nfunc (s *Store) DeleteWorkspace(ctx context.Context, id workspace.ID) error\n```\nDeleteWorkspace relies on every table cascading from workspaces, so a table added later goes with it without changes here.\n\n```go\nfunc (s *Store) DueQueues(ctx context.Context, now time.Time) ([]store.Queue, error)\n```\n\n```go\nfunc (s *Store) DueSchedules(ctx context.Context, now time.Time) ([]store.Schedule, error)\n```\n\n```go\nfunc (s *Store) EnsureWorkspace(ctx context.Context, id workspace.ID, name string) (store.Workspace, error)\n```\n\n```go\nfunc (s *Store) ExpireWorkflowRuns(ctx context.Context, now time.Time, limit int) (int, error)\n```\n\n```go\nfunc (s *Store) ExpiredLeases(ctx context.Context, now time.Time, limit int) ([]store.Task, error)\n```\n\n```go\nfunc (s *Store) ExpiredRunLeases(ctx context.Context, now time.Time, limit int) ([]store.Run, error)\n```\n\n```go\nfunc (s *Store) FailuresToAlert(ctx context.Context, ws workspace.ID, w store.AlertWindow) ([]store.AlertFailures, error)\n```\n\n```go\nfunc (s *Store) FinishAttempt(ctx context.Context, ws workspace.ID, r store.AttemptResult) (store.TaskState, error)\n```\n\n```go\nfunc (s *Store) FinishAttempts(ctx context.Context, rs []store.FinishedAttempt) ([]store.FinishOutcome, error)\n```\n\n```go\nfunc (s *Store) FinishRunAttempt(ctx context.Context, ws workspace.ID, r store.RunAttemptResult) (store.RunState, error)\n```\n\n```go\nfunc (s *Store) FinishedActivity(ctx context.Context, ws workspace.ID, since time.Time, bucket time.Duration) ([]store.FinishedCount, error)\n```\n\n```go\nfunc (s *Store) FireSchedule(ctx context.Context, f store.Fire, now time.Time) (store.Run, bool, error)\n```\n\n```go\nfunc (s *Store) GetAlertChannel(ctx context.Context, ws workspace.ID, channelID string) (store.AlertChannel, error)\n```\n\n```go\nfunc (s *Store) GetGroup(ctx context.Context, ws workspace.ID, id string) (store.Group, error)\n```\n\n```go\nfunc (s *Store) GetQueue(ctx context.Context, ws workspace.ID, name string) (store.Queue, error)\n```\n\n```go\nfunc (s *Store) GetRun(ctx context.Context, ws workspace.ID, id string) (store.Run, error)\n```\n\n```go\nfunc (s *Store) GetSchedule(ctx context.Context, ws workspace.ID, name string) (store.Schedule, error)\n```\n\n```go\nfunc (s *Store) GetTask(ctx context.Context, ws workspace.ID, id string) (store.Task, error)\n```\n\n```go\nfunc (s *Store) GetWorkflow(ctx context.Context, ws workspace.ID, name string) (store.Workflow, error)\n```\n\n```go\nfunc (s *Store) GetWorkflowRun(ctx context.Context, ws workspace.ID, id string) (store.WorkflowRun, error)\n```\n\n```go\nfunc (s *Store) GetWorkspace(ctx context.Context, id workspace.ID) (store.Workspace, error)\n```\n\n```go\nfunc (s *Store) ListAlertChannels(ctx context.Context, ws workspace.ID) ([]store.AlertChannel, error)\n```\n\n```go\nfunc (s *Store) ListAttempts(ctx context.Context, ws workspace.ID, taskID string) ([]store.Attempt, error)\n```\n\n```go\nfunc (s *Store) ListGroups(ctx context.Context, ws workspace.ID, f store.GroupFilter) ([]store.Group, string, error)\n```\n\n```go\nfunc (s *Store) ListQueues(ctx context.Context, ws workspace.ID) ([]store.Queue, error)\n```\n\n```go\nfunc (s *Store) ListRunAttempts(ctx context.Context, ws workspace.ID, runID string) ([]store.Attempt, error)\n```\n\n```go\nfunc (s *Store) ListRuns(ctx context.Context, ws workspace.ID, f store.RunFilter) ([]store.Run, string, error)\n```\n\n```go\nfunc (s *Store) ListSchedules(ctx context.Context, ws workspace.ID) ([]store.Schedule, error)\n```\n\n```go\nfunc (s *Store) ListTasks(ctx context.Context, ws workspace.ID, f store.TaskFilter) ([]store.Task, string, error)\n```\n\n```go\nfunc (s *Store) ListWorkflowRuns(ctx context.Context, ws workspace.ID, f store.WorkflowRunFilter) ([]store.WorkflowRun, string, error)\n```\n\n```go\nfunc (s *Store) ListWorkflows(ctx context.Context, ws workspace.ID) ([]store.Workflow, error)\n```\n\n```go\nfunc (s *Store) MarkAlerted(ctx context.Context, ws workspace.ID, subjects []store.AlertSubject, at time.Time) error\n```\n\n```go\nfunc (s *Store) NextRunAt(ctx context.Context, after time.Time) (time.Time, bool, error)\n```\n\n```go\nfunc (s *Store) NextScheduleWork(ctx context.Context, after time.Time) (time.Time, bool, error)\n```\n\n```go\nfunc (s *Store) ProbeFailed(ctx context.Context, ws workspace.ID, name, errMsg string, nextProbe time.Time) error\n```\n\n```go\nfunc (s *Store) PutQueue(ctx context.Context, ws workspace.ID, name string, cfg store.QueueConfig) (store.Queue, bool, error)\n```\n\n```go\nfunc (s *Store) PutSchedule(ctx context.Context, ws workspace.ID, name string, cfg store.ScheduleConfig, nextRunAt time.Time) (store.Schedule, bool, error)\n```\n\n```go\nfunc (s *Store) PutWorkflow(ctx context.Context, ws workspace.ID, name string, cfg store.WorkflowConfig) (store.Workflow, bool, error)\n```\n\n```go\nfunc (s *Store) QueueActivity(ctx context.Context, ws workspace.ID, queue string, since time.Time) (store.QueueActivity, error)\n```\n\n```go\nfunc (s *Store) QueueFailures(ctx context.Context, ws workspace.ID, queue string, limit int) ([]store.FailureGroup, error)\n```\n\n```go\nfunc (s *Store) QueueStats(ctx context.Context, ws workspace.ID, name string, now time.Time) (map[string]store.QueueStats, error)\n```\n\n```go\nfunc (s *Store) RetryFailedTasks(ctx context.Context, ws workspace.ID, queue, lastError string) (int, error)\n```\n\n```go\nfunc (s *Store) RetryRun(ctx context.Context, ws workspace.ID, id string) (store.Run, error)\n```\n\n```go\nfunc (s *Store) RetryTask(ctx context.Context, ws workspace.ID, id string) (store.Task, error)\n```\n\n```go\nfunc (s *Store) RetryWorkflowRun(ctx context.Context, ws workspace.ID, id string, now time.Time) (store.WorkflowRun, error)\n```\n\n```go\nfunc (s *Store) SetQueuePaused(ctx context.Context, ws workspace.ID, name string, paused bool) (store.Queue, error)\n```\n\n```go\nfunc (s *Store) SetSchedulePaused(ctx context.Context, ws workspace.ID, name string, paused bool, nextRunAt time.Time) (store.Schedule, error)\n```\n\n```go\nfunc (s *Store) StartWorkflowRun(ctx context.Context, ws workspace.ID, name string, nr store.NewWorkflowRun, now time.Time) (store.WorkflowRun, bool, error)\n```\n\n```go\nfunc (s *Store) TaskActivity(ctx context.Context, ws workspace.ID, since time.Time, bucket time.Duration) ([]store.ActivityCount, error)\n```\n\n```go\nfunc (s *Store) TriggerSchedule(ctx context.Context, ws workspace.ID, name string, now time.Time) (store.Run, error)\n```\n\n","path":"github.com/worklydev/workly/internal/store/sqlstore","name":"sqlstore","synopsis":"Package sqlstore holds the SQL shared by the postgres and sqlite stores.","isRedistributable":true}
