Versions in this module Expand all Collapse all v0 v0.4.0 Nov 24, 2026 Changes in this version + func TimeText(t time.Time) string + type Anchor struct + ID string + Mode LockMode + Table string + type Dialect interface + BindBool func(b bool) any + BindTime func(t time.Time) any + CIEqual func(col string) string + CILike func(col string) string + Classify func(err error) ErrClass + ClockMicros func() string + EpochSeconds func(expr string) string + ForShare func() string + ForUpdate func() string + LockAnchors func(ctx context.Context, tx *sql.Tx, anchors ...Anchor) error + Rebind func(query string) string + type ErrClass int + const ErrClassConflict + const ErrClassNotFound + const ErrClassOther + const ErrClassRetry + type LockMode int + const LockNoKeyUpdate + const LockShare + const LockUpdate + type Option func(*Store) + func WithForcedRetry() Option + func WithLeasePool(db *sql.DB) Option + func WithLogger(l *slog.Logger) Option + func WithTaskInsertBatch(rows int) Option + type Store struct + func New(ctx context.Context, write, read *sql.DB, d Dialect, opts ...Option) (*Store, error) + func (s *Store) AbortRetirement(ctx context.Context, workerID string, now time.Time, reason string) (bool, error) + func (s *Store) AcquireLeadership(ctx context.Context, holder string, ttl time.Duration) (epoch int64, ok bool, err error) + func (s *Store) ActiveClaimCount(ctx context.Context, poolID string) (int, error) + func (s *Store) AppendAuditEntry(ctx context.Context, entry store.AuditEntry) error + func (s *Store) BeginRetirement(ctx context.Context, groupID, workerID string, now time.Time) (store.Worker, bool, error) + func (s *Store) CancelBlockedJob(ctx context.Context, id, reason string, now time.Time) (bool, []store.Task, error) + func (s *Store) CancelJobExecution(ctx context.Context, jobID, reason string, now time.Time) ([]store.Task, error) + func (s *Store) CancelJobStatus(ctx context.Context, id string) error + func (s *Store) CancelPendingStep(ctx context.Context, id, reason string, now time.Time) (bool, []store.Task, error) + func (s *Store) CancelTaskExecution(ctx context.Context, taskID, reason string, now time.Time) (store.Task, bool, error) + func (s *Store) ClaimInvariantViolations(ctx context.Context) ([]string, error) + func (s *Store) Close() error + func (s *Store) CommittedCores(ctx context.Context, workerID string, fullMachineCost int) (int, error) + func (s *Store) CompleteTaskAttempt(ctx context.Context, c store.AttemptCompletion) (store.CompletionResult, error) + func (s *Store) CountActiveTasksInFarm(ctx context.Context, farmID string) (int, error) + func (s *Store) CountActiveTasksInQueue(ctx context.Context, queueID string) (int, error) + func (s *Store) CountIdleWorkers(ctx context.Context, farmID string) (int, error) + func (s *Store) CountReadyTasksByQueue(ctx context.Context, farmID string, now time.Time) (map[string]int, error) + func (s *Store) CountTasksByJob(ctx context.Context, jobID string) (map[store.TaskStatus]int, error) + func (s *Store) CountUnschedulableTasksByJob(ctx context.Context, jobID string) (int, error) + func (s *Store) CountUsers(ctx context.Context) (int, error) + func (s *Store) CreateAPIKey(ctx context.Context, k store.APIKey) (store.APIKey, error) + func (s *Store) CreateCapacityGroup(ctx context.Context, g store.CapacityGroup) (store.CapacityGroup, error) + func (s *Store) CreateComputeLocation(ctx context.Context, loc store.ComputeLocation) (store.ComputeLocation, error) + func (s *Store) CreateFarm(ctx context.Context, farm store.Farm) (store.Farm, error) + func (s *Store) CreateJobSubmission(ctx context.Context, sub store.JobSubmission) (store.JobSubmission, error) + func (s *Store) CreateProduct(ctx context.Context, p store.Product) (store.Product, error) + func (s *Store) CreateQueue(ctx context.Context, queue store.Queue) (store.Queue, error) + func (s *Store) CreateSession(ctx context.Context, sess store.Session) (store.Session, error) + func (s *Store) CreateStorageLocation(ctx context.Context, loc store.StorageLocation) (store.StorageLocation, error) + func (s *Store) CreateTaskLog(ctx context.Context, log store.TaskLog) (store.TaskLog, error) + func (s *Store) CreateUsagePool(ctx context.Context, pool store.UsagePool) (store.UsagePool, error) + func (s *Store) CreateUser(ctx context.Context, u store.User) (store.User, error) + func (s *Store) CreateWorkerCredential(ctx context.Context, c store.WorkerCredential) (store.WorkerCredential, error) + func (s *Store) CreateWorkerJoinToken(ctx context.Context, t store.WorkerJoinToken) (store.WorkerJoinToken, error) + func (s *Store) DeleteCapacityGroup(ctx context.Context, id string) error + func (s *Store) DeleteComputeLocation(ctx context.Context, id string) error + func (s *Store) DeleteEphemeralWorker(ctx context.Context, id string, now time.Time) (store.Worker, bool, error) + func (s *Store) DeleteExpiredSessions(ctx context.Context, now time.Time) (int, error) + func (s *Store) DeleteFarm(ctx context.Context, id string) error + func (s *Store) DeleteJob(ctx context.Context, id string) error + func (s *Store) DeleteOfflineWorkersBefore(ctx context.Context, cutoff time.Time) ([]store.Worker, error) + func (s *Store) DeleteProduct(ctx context.Context, name string) error + func (s *Store) DeleteQueue(ctx context.Context, id string) error + func (s *Store) DeleteServerMembersUnseenFor(ctx context.Context, d time.Duration) (int, error) + func (s *Store) DeleteSession(ctx context.Context, id string) error + func (s *Store) DeleteStorageLocation(ctx context.Context, id string) error + func (s *Store) DeleteTerminalJobsBefore(ctx context.Context, cutoff time.Time, includeFailed bool) ([]store.DeletedJob, error) + func (s *Store) DeleteUsagePool(ctx context.Context, id string) error + func (s *Store) DeleteUser(ctx context.Context, id string) error + func (s *Store) DeleteVanishedEphemeralWorker(ctx context.Context, id string, cutoff, now time.Time) (store.Worker, bool, error) + func (s *Store) DeleteWorkerIfRemovable(ctx context.Context, id string) error + func (s *Store) DemoteStalledJobs(ctx context.Context, now time.Time) ([]string, error) + func (s *Store) ExpireRetirements(ctx context.Context, groupID string, cutoff, now time.Time, reason string) ([]string, error) + func (s *Store) FailWakes(ctx context.Context, groupID string, cutoff, now time.Time, reason string) ([]string, error) + func (s *Store) FailureReasonSummary(ctx context.Context, jobID string) (store.FailureSummary, error) + func (s *Store) FinalizeJob(ctx context.Context, id string, now time.Time) (store.JobStatus, bool, error) + func (s *Store) FinalizeStep(ctx context.Context, id string, now time.Time) (store.StepStatus, bool, error) + func (s *Store) FinishRetirement(ctx context.Context, workerID string, now time.Time) (w store.Worker, deleted, ok bool, err error) + func (s *Store) GetAPIKeyUserByTokenHash(ctx context.Context, tokenHash string, now time.Time) (store.APIKey, store.User, error) + func (s *Store) GetActiveWorkerCredentialByPublicKey(ctx context.Context, publicKey string) (store.WorkerCredential, error) + func (s *Store) GetBrokerIdentity(ctx context.Context) (string, error) + func (s *Store) GetCapacityGroup(ctx context.Context, id string) (store.CapacityGroup, error) + func (s *Store) GetCapacityGroupByName(ctx context.Context, name string) (store.CapacityGroup, error) + func (s *Store) GetComputeLocation(ctx context.Context, id string) (store.ComputeLocation, error) + func (s *Store) GetComputeLocationByName(ctx context.Context, name string) (store.ComputeLocation, error) + func (s *Store) GetFarm(ctx context.Context, id string) (store.Farm, error) + func (s *Store) GetJob(ctx context.Context, id string) (store.Job, error) + func (s *Store) GetLeadership(ctx context.Context) (store.Lease, error) + func (s *Store) GetProductByName(ctx context.Context, name string) (store.Product, error) + func (s *Store) GetQueue(ctx context.Context, id string) (store.Queue, error) + func (s *Store) GetSessionByTokenHash(ctx context.Context, tokenHash string, now time.Time) (store.Session, error) + func (s *Store) GetSessionUserByTokenHash(ctx context.Context, tokenHash string, now time.Time) (store.User, error) + func (s *Store) GetStep(ctx context.Context, id string) (store.Step, error) + func (s *Store) GetStorageLocation(ctx context.Context, id string) (store.StorageLocation, error) + func (s *Store) GetStorageLocationByName(ctx context.Context, name string) (store.StorageLocation, error) + func (s *Store) GetTask(ctx context.Context, id string) (store.Task, error) + func (s *Store) GetTaskAttempt(ctx context.Context, id string) (store.TaskAttempt, error) + func (s *Store) GetUsagePool(ctx context.Context, id string) (store.UsagePool, error) + func (s *Store) GetUser(ctx context.Context, id string) (store.User, error) + func (s *Store) GetUserByExternalID(ctx context.Context, authSource, externalID string) (store.User, error) + func (s *Store) GetUserByUsername(ctx context.Context, username string) (store.User, error) + func (s *Store) GetWorker(ctx context.Context, id string) (store.Worker, error) + func (s *Store) GetWorkerJoinTokenByHash(ctx context.Context, hash string) (store.WorkerJoinToken, error) + func (s *Store) InjectClaim(ctx context.Context, claim store.UsageClaim) (store.UsageClaim, error) + func (s *Store) InjectTaskAttempt(ctx context.Context, attempt store.TaskAttempt) (store.TaskAttempt, error) + func (s *Store) InjectWorkerPowerState(ctx context.Context, workerID string, state store.PowerState, at time.Time, ...) error + func (s *Store) JobTimings(ctx context.Context, jobIDs []string) (map[string]store.JobTiming, error) + func (s *Store) LatestAttemptProgress(ctx context.Context, taskIDs []string) (map[string]store.TaskProgress, error) + func (s *Store) LatestTaskAttempt(ctx context.Context, taskID string) (store.TaskAttempt, error) + func (s *Store) LeaseTask(ctx context.Context, req store.LeaseRequest) (store.LeaseResult, error) + func (s *Store) ListAPIKeysForUser(ctx context.Context, userID string) ([]store.APIKey, error) + func (s *Store) ListActiveWorkerCredentials(ctx context.Context) ([]store.WorkerCredential, error) + func (s *Store) ListAuditEntries(ctx context.Context, entityType, entityID string) ([]store.AuditEntry, error) + func (s *Store) ListBlockedJobs(ctx context.Context) ([]store.Job, error) + func (s *Store) ListCapacityGroupMembers(ctx context.Context, groupID string) ([]store.Worker, error) + func (s *Store) ListCapacityGroupStates(ctx context.Context) (map[string]store.CapacityGroupState, error) + func (s *Store) ListCapacityGroupTokens(ctx context.Context, groupID string) ([]store.WorkerJoinToken, error) + func (s *Store) ListCapacityGroups(ctx context.Context) ([]store.CapacityGroup, error) + func (s *Store) ListComputeLocations(ctx context.Context) ([]store.ComputeLocation, error) + func (s *Store) ListDependents(ctx context.Context, upstreamJobID string) ([]string, error) + func (s *Store) ListFarms(ctx context.Context) ([]store.Farm, error) + func (s *Store) ListJobDependencyIDs(ctx context.Context, jobID string) ([]string, error) + func (s *Store) ListJobIDsWithPendingSteps(ctx context.Context) ([]string, error) + func (s *Store) ListJobs(ctx context.Context, opts store.ListJobsOptions) (store.Page[store.Job], error) + func (s *Store) ListOpenAttempts(ctx context.Context) ([]store.OpenAttempt, error) + func (s *Store) ListProducts(ctx context.Context) ([]store.Product, error) + func (s *Store) ListQueues(ctx context.Context, opts store.ListQueuesOptions) (store.Page[store.Queue], error) + func (s *Store) ListReadyStepDemand(ctx context.Context, farmID string, now time.Time) ([]store.StepDemand, error) + func (s *Store) ListReadyTasks(ctx context.Context, farmID string, now time.Time, limit int) ([]store.Task, error) + func (s *Store) ListServerMembers(ctx context.Context) ([]store.ServerMember, int64, error) + func (s *Store) ListStaleWorkers(ctx context.Context, before time.Time) ([]store.Worker, error) + func (s *Store) ListSteps(ctx context.Context, jobID string) ([]store.Step, error) + func (s *Store) ListStorageLocations(ctx context.Context) ([]store.StorageLocation, error) + func (s *Store) ListStuckSteps(ctx context.Context) ([]store.Step, error) + func (s *Store) ListTaskAttempts(ctx context.Context, taskID string) ([]store.TaskAttempt, error) + func (s *Store) ListTaskLogs(ctx context.Context, attemptID string, afterNATSSeq int64, limit int) ([]store.TaskLog, error) + func (s *Store) ListTasks(ctx context.Context, opts store.ListTasksOptions) (store.Page[store.Task], error) + func (s *Store) ListUsagePoolUtilization(ctx context.Context) ([]store.UsagePoolUtilization, error) + func (s *Store) ListUsagePools(ctx context.Context) ([]store.UsagePool, error) + func (s *Store) ListUsers(ctx context.Context) ([]store.User, error) + func (s *Store) ListWorkerCommitments(ctx context.Context, farmID string) (map[string]store.WorkerCommitment, error) + func (s *Store) ListWorkers(ctx context.Context, opts store.ListWorkersOptions) (store.Page[store.Worker], error) + func (s *Store) MarkWaking(ctx context.Context, groupID string, workerIDs []string, now time.Time) ([]string, error) + func (s *Store) MarkWorkerJoinTokenUsed(ctx context.Context, id string, at time.Time) error + func (s *Store) OfflineStaleWorker(ctx context.Context, id string, cutoff, now time.Time) ([]store.Task, bool, error) + func (s *Store) OfflineWorker(ctx context.Context, id, instanceID string, now time.Time) ([]store.Task, bool, error) + func (s *Store) ParkJob(ctx context.Context, jobID, reason string, now time.Time) error + func (s *Store) PauseJob(ctx context.Context, id string, now time.Time) error + func (s *Store) PromoteJobRunning(ctx context.Context, id string, now time.Time) (bool, error) + func (s *Store) PutCapacityGroupState(ctx context.Context, st store.CapacityGroupState) error + func (s *Store) QueueJobTimings(ctx context.Context, queueIDs []string) ([]store.JobTiming, error) + func (s *Store) ReclaimStaleAssignedTasks(ctx context.Context, cutoff time.Time, skip map[string]bool) ([]store.Task, error) + func (s *Store) ReclaimTaskAttempt(ctx context.Context, attemptID, taskID string, now time.Time) (bool, error) + func (s *Store) RecordAttemptProgress(ctx context.Context, p store.AttemptProgress) (store.ProgressOutcome, string, error) + func (s *Store) RecordTaskFailure(ctx context.Context, attemptID, taskID string, exitCode *int, ...) (taskFailed, jobFailed int, firstClose bool, err error) + func (s *Store) RedeemWorkerJoinToken(ctx context.Context, hash string, now time.Time, cred store.WorkerCredential) (store.WorkerCredential, error) + func (s *Store) RegisterWorker(ctx context.Context, worker store.Worker) (store.Worker, store.Registration, error) + func (s *Store) ReleaseBlockedJob(ctx context.Context, id string, now time.Time) (bool, error) + func (s *Store) ReleaseLeadership(ctx context.Context, holder string, epoch int64) error + func (s *Store) ReleaseStep(ctx context.Context, id string, now time.Time) (bool, []store.Task, error) + func (s *Store) RenewLeadership(ctx context.Context, holder string, epoch int64, ttl time.Duration) (bool, error) + func (s *Store) RequeueTaskForRetry(ctx context.Context, taskID, attemptID string, retryAfter, now time.Time) (bool, error) + func (s *Store) ResumeJob(ctx context.Context, jobID string, now time.Time) error + func (s *Store) RetryTasks(ctx context.Context, jobID string, taskIDs []string, now time.Time) ([]store.Task, error) + func (s *Store) RevokeAPIKey(ctx context.Context, id, userID string, now time.Time) error + func (s *Store) RevokeCapacityGroupToken(ctx context.Context, groupID, id string, at time.Time) error + func (s *Store) RevokeWorkerCredential(ctx context.Context, workerID string, at time.Time) error + func (s *Store) RunningProgressByJob(ctx context.Context, jobID string) (float64, error) + func (s *Store) RunningProgressByJobs(ctx context.Context, jobIDs []string) (map[string]float64, error) + func (s *Store) SetBrokerIdentity(ctx context.Context, identity string, at time.Time) error + func (s *Store) SetTaskUnschedulableReason(ctx context.Context, id, reason string) (bool, error) + func (s *Store) SetUserDisplayName(ctx context.Context, id, displayName string) (store.User, error) + func (s *Store) SetUserPassword(ctx context.Context, id, passwordHash string) error + func (s *Store) SetUserPasswordAndEvictSessions(ctx context.Context, id, passwordHash string) error + func (s *Store) SetWorkerCapacityGroup(ctx context.Context, workerID, groupID string, ephemeral bool) (store.Worker, error) + func (s *Store) SetWorkerDisabled(ctx context.Context, id string, disabled bool) (store.Worker, error) + func (s *Store) StartTaskAttempt(ctx context.Context, attemptID, taskID, sessionID string, now time.Time) (bool, error) + func (s *Store) TouchAPIKeyLastUsed(ctx context.Context, id string, now time.Time) error + func (s *Store) TouchWorkerCredential(ctx context.Context, workerID string, at time.Time) (store.WorkerCredential, error) + func (s *Store) TxRetries() int64 + func (s *Store) UpdateCapacityGroup(ctx context.Context, g store.CapacityGroup) (store.CapacityGroup, error) + func (s *Store) UpdateComputeLocation(ctx context.Context, loc store.ComputeLocation) (store.ComputeLocation, error) + func (s *Store) UpdateFarm(ctx context.Context, farm store.Farm) (store.Farm, error) + func (s *Store) UpdateJob(ctx context.Context, job store.Job) (store.Job, error) + func (s *Store) UpdateProduct(ctx context.Context, p store.Product) (store.Product, error) + func (s *Store) UpdateQueue(ctx context.Context, queue store.Queue) (store.Queue, error) + func (s *Store) UpdateStorageLocation(ctx context.Context, loc store.StorageLocation) (store.StorageLocation, error) + func (s *Store) UpdateUsagePool(ctx context.Context, pool store.UsagePool) (store.UsagePool, error) + func (s *Store) UpdateUser(ctx context.Context, u store.User) (store.User, error) + func (s *Store) UpdateUserKeepingAdmin(ctx context.Context, u store.User) (store.User, error) + func (s *Store) UpdateWorkerHeartbeat(ctx context.Context, id string, at time.Time, brokerAt, startedAt *time.Time) (store.HeartbeatOutcome, error) + func (s *Store) UpsertServerMember(ctx context.Context, m store.ServerMember) error