fake

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package fake provides an in-memory implementation of store.Store for unit tests that must avoid touching the filesystem.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is an in-memory implementation of store.Store for unit tests that must avoid touching the filesystem.

func New

func New() *Store

New returns a ready-to-use in-memory store.

func (*Store) ActiveClaimCount

func (s *Store) ActiveClaimCount(_ context.Context, poolID string) (int, error)

ActiveClaimCount returns the number of claims for the given pool where ReleasedAt IS NULL.

func (*Store) AppendAuditEntry

func (s *Store) AppendAuditEntry(_ context.Context, entry store.AuditEntry) error

AppendAuditEntry inserts a new audit log entry.

func (*Store) AssignTask

func (s *Store) AssignTask(_ context.Context, id, workerID string, assignedAt time.Time) error

AssignTask atomically sets AssignedWorkerID, AssignedAt, and Status to store.TaskStatusAssigned for the given task.

func (*Store) CancelJobAttempts

func (s *Store) CancelJobAttempts(_ context.Context, jobID string, endedAt time.Time) (int, error)

CancelJobAttempts marks all running store.TaskAttempt records for tasks belonging to the given job as store.AttemptStatusCanceled.

func (*Store) CancelJobStatus

func (s *Store) CancelJobStatus(_ context.Context, id string) error

CancelJobStatus implements store.JobStore. Transitions the job to canceled unless it is already completed or failed.

func (*Store) CancelJobTasks

func (s *Store) CancelJobTasks(_ context.Context, jobID string, now time.Time, reason string) ([]store.Task, error)

CancelJobTasks transitions all non-terminal tasks for the given job to store.TaskStatusCanceled, stamping a non-empty reason on tasks that carry no failure reason yet, and returns those that were in store.TaskStatusAssigned or store.TaskStatusRunning at call time.

func (*Store) Close

func (*Store) Close() error

Close implements io.Closer; it is a no-op for the in-memory store.

func (*Store) CommittedCores

func (s *Store) CommittedCores(_ context.Context, workerID string, fullMachineCost int) (int, error)

CommittedCores implements store.TaskStore.

func (*Store) CountActiveTasksInFarm

func (s *Store) CountActiveTasksInFarm(_ context.Context, farmID string) (int, error)

CountActiveTasksInFarm returns the number of tasks in 'assigned' or 'running' state whose job belongs to farmID.

func (*Store) CountActiveTasksInQueue

func (s *Store) CountActiveTasksInQueue(_ context.Context, queueID string) (int, error)

CountActiveTasksInQueue returns the number of tasks in 'assigned' or 'running' state whose job belongs to queueID.

func (*Store) CountIdleWorkers

func (s *Store) CountIdleWorkers(_ context.Context, farmID string) (int, error)

CountIdleWorkers returns the number of online workers in the given farm that have no task in store.TaskStatusAssigned or store.TaskStatusRunning state. When farmID is empty all farms are counted.

func (*Store) CountReadyTasksByQueue

func (s *Store) CountReadyTasksByQueue(_ context.Context, farmID string, now time.Time) (map[string]int, error)

CountReadyTasksByQueue returns the number of leasable ready tasks for each queue in the given farm ("" = all farms), keyed by queue ID — the same eligibility predicate as ListReadyTasks (see isReadyInFarm).

func (*Store) CountTasksByJob

func (s *Store) CountTasksByJob(_ context.Context, jobID string) (map[store.TaskStatus]int, error)

CountTasksByJob returns the number of tasks for the given job keyed by status. Statuses with zero tasks are omitted from the returned map.

func (*Store) CountUnschedulableTasksByJob added in v0.2.0

func (s *Store) CountUnschedulableTasksByJob(_ context.Context, jobID string) (int, error)

CountUnschedulableTasksByJob returns the number of ready tasks for the given job that carry a non-empty unschedulable reason.

func (*Store) CreateClaim

func (s *Store) CreateClaim(_ context.Context, claim store.UsageClaim) (store.UsageClaim, error)

CreateClaim inserts a new active claim for the given pool and task attempt. The (TaskAttemptID, PoolID) pair must be unique; returns store.ErrConflict if violated.

func (*Store) CreateComputeLocation added in v0.2.0

func (s *Store) CreateComputeLocation(_ context.Context, loc store.ComputeLocation) (store.ComputeLocation, error)

CreateComputeLocation inserts a new location. Returns store.ErrConflict if a location with the same name already exists.

func (*Store) CreateFarm

func (s *Store) CreateFarm(_ context.Context, farm store.Farm) (store.Farm, error)

CreateFarm inserts a new farm. Returns store.ErrConflict if a farm with the same name already exists.

func (*Store) CreateJob

func (s *Store) CreateJob(_ context.Context, job store.Job) (store.Job, error)

CreateJob inserts a new job with all fields populated by the caller.

func (*Store) CreateJobDependencies added in v0.2.0

func (s *Store) CreateJobDependencies(_ context.Context, jobID string, upstreamIDs []string) error

CreateJobDependencies records that jobID waits on each upstream ID. Duplicate edges (already-recorded upstream IDs) are ignored.

func (*Store) CreateProduct added in v0.2.0

func (s *Store) CreateProduct(_ context.Context, p store.Product) (store.Product, error)

CreateProduct inserts a product. Returns store.ErrConflict on duplicate name.

func (*Store) CreateQueue

func (s *Store) CreateQueue(_ context.Context, queue store.Queue) (store.Queue, error)

CreateQueue inserts a new queue. Returns store.ErrConflict if a queue with the same name already exists within the same farm.

func (*Store) CreateStep

func (s *Store) CreateStep(_ context.Context, step store.Step) (store.Step, error)

CreateStep inserts a new step. The (JobID, Name) pair must be unique within the job; returns store.ErrConflict if violated.

func (*Store) CreateStorageLocation

func (s *Store) CreateStorageLocation(_ context.Context, loc store.StorageLocation) (store.StorageLocation, error)

CreateStorageLocation inserts a new location. Returns store.ErrConflict if a location with the same name already exists.

func (*Store) CreateTask

func (s *Store) CreateTask(_ context.Context, task store.Task) (store.Task, error)

CreateTask inserts a new task.

func (*Store) CreateTaskAttempt

func (s *Store) CreateTaskAttempt(_ context.Context, attempt store.TaskAttempt) (store.TaskAttempt, error)

CreateTaskAttempt inserts a new attempt record.

func (*Store) CreateTaskLog

func (s *Store) CreateTaskLog(_ context.Context, log store.TaskLog) (store.TaskLog, error)

CreateTaskLog implements store.TaskLogStore.

func (*Store) CreateUsagePool

func (s *Store) CreateUsagePool(_ context.Context, pool store.UsagePool) (store.UsagePool, error)

CreateUsagePool inserts a new pool. Returns store.ErrConflict if a pool with the same name (compared case-insensitively) already exists.

func (*Store) DeleteComputeLocation added in v0.2.0

func (s *Store) DeleteComputeLocation(_ context.Context, id string) error

DeleteComputeLocation removes a location by ID. Returns store.ErrNotFound if it does not exist.

func (*Store) DeleteFarm

func (s *Store) DeleteFarm(_ context.Context, id string) error

DeleteFarm removes a farm by ID. Returns store.ErrNotFound if it does not exist.

func (*Store) DeleteJob

func (s *Store) DeleteJob(_ context.Context, id string) error

DeleteJob implements store.JobStore. It removes the job and every in-memory row that belongs to it: usage claims (by attempt), task logs (by task), task attempts, tasks, and steps, mirroring the SQLite cascade. Returns store.ErrNotFound when the job is absent.

func (*Store) DeleteOfflineWorkersBefore

func (s *Store) DeleteOfflineWorkersBefore(_ context.Context, cutoff time.Time) ([]store.Worker, error)

DeleteOfflineWorkersBefore hard-deletes every offline worker last seen before cutoff and returns the removed records. Non-offline workers (including disabled) and workers that have never sent a heartbeat are left untouched.

func (*Store) DeleteProduct added in v0.2.0

func (s *Store) DeleteProduct(_ context.Context, name string) error

DeleteProduct removes the product with the given name.

func (*Store) DeleteQueue

func (s *Store) DeleteQueue(_ context.Context, id string) error

DeleteQueue removes a queue by ID. Returns store.ErrNotFound if it does not exist.

func (*Store) DeleteStorageLocation

func (s *Store) DeleteStorageLocation(_ context.Context, id string) error

DeleteStorageLocation removes a location by ID. Returns store.ErrNotFound if it does not exist.

func (*Store) DeleteTerminalJobsBefore

func (s *Store) DeleteTerminalJobsBefore(
	ctx context.Context, cutoff time.Time, includeFailed bool,
) ([]store.DeletedJob, error)

DeleteTerminalJobsBefore implements store.JobStore. completed and canceled jobs are always eligible; failed jobs only when includeFailed. Effective completion time is CompletedAt, falling back to UpdatedAt when nil.

A candidate still referenced as an upstream (depends_on_job_id) by a non-terminal dependent is skipped: purging it would leave the dependent's reconciler reading a GetJob ErrNotFound for an upstream that actually succeeded, which it treats as "missing" and wrongly cancels the dependent. Manual DeleteJob intentionally keeps the cancel-dependents behavior — this guard only applies to the automatic retention sweep.

func (*Store) DeleteUsagePool

func (s *Store) DeleteUsagePool(_ context.Context, id string) error

DeleteUsagePool removes a pool by ID. Returns store.ErrNotFound if it does not exist.

func (*Store) DeleteWorker

func (s *Store) DeleteWorker(_ context.Context, id string) error

DeleteWorker hard-deletes the worker with the given ID.

func (*Store) DemoteStalledJobs

func (s *Store) DemoteStalledJobs(_ context.Context, now time.Time) ([]string, error)

DemoteStalledJobs implements store.JobStore. It returns every running job with no assigned/running task — but at least one ready/pending task — to pending, and returns the demoted job IDs.

func (*Store) FailureReasonSummary added in v0.2.0

func (s *Store) FailureReasonSummary(_ context.Context, jobID string) (store.FailureSummary, error)

FailureReasonSummary implements store.TaskStore. It mirrors the sqlite group-by-then-order-by(n DESC, reason ASC) semantics: the dominant reason is the most frequent one, ties broken by reason string ascending.

func (*Store) GetComputeLocation added in v0.2.0

func (s *Store) GetComputeLocation(_ context.Context, id string) (store.ComputeLocation, error)

GetComputeLocation returns the location with the given ID, or store.ErrNotFound.

func (*Store) GetComputeLocationByName added in v0.2.0

func (s *Store) GetComputeLocationByName(_ context.Context, name string) (store.ComputeLocation, error)

GetComputeLocationByName returns the location with the given name, or store.ErrNotFound. The match is exact (case-sensitive).

func (*Store) GetFarm

func (s *Store) GetFarm(_ context.Context, id string) (store.Farm, error)

GetFarm returns the farm with the given ID, or store.ErrNotFound.

func (*Store) GetJob

func (s *Store) GetJob(_ context.Context, id string) (store.Job, error)

GetJob returns the job with the given ID, or store.ErrNotFound.

func (*Store) GetProductByName added in v0.2.0

func (s *Store) GetProductByName(_ context.Context, name string) (store.Product, error)

GetProductByName returns the product with the given name, or store.ErrNotFound.

func (*Store) GetQueue

func (s *Store) GetQueue(_ context.Context, id string) (store.Queue, error)

GetQueue returns the queue with the given ID, or store.ErrNotFound.

func (*Store) GetStep

func (s *Store) GetStep(_ context.Context, id string) (store.Step, error)

GetStep returns the step with the given ID, or store.ErrNotFound.

func (*Store) GetStorageLocation

func (s *Store) GetStorageLocation(_ context.Context, id string) (store.StorageLocation, error)

GetStorageLocation returns the location with the given ID, or store.ErrNotFound.

func (*Store) GetStorageLocationByName

func (s *Store) GetStorageLocationByName(_ context.Context, name string) (store.StorageLocation, error)

GetStorageLocationByName returns the location with the given name, or store.ErrNotFound.

func (*Store) GetTask

func (s *Store) GetTask(_ context.Context, id string) (store.Task, error)

GetTask returns the task with the given ID, or store.ErrNotFound.

func (*Store) GetTaskAttempt

func (s *Store) GetTaskAttempt(_ context.Context, id string) (store.TaskAttempt, error)

GetTaskAttempt returns the attempt with the given ID, or store.ErrNotFound.

func (*Store) GetUsagePool

func (s *Store) GetUsagePool(_ context.Context, id string) (store.UsagePool, error)

GetUsagePool returns the pool with the given ID, or store.ErrNotFound.

func (*Store) GetWorker

func (s *Store) GetWorker(_ context.Context, id string) (store.Worker, error)

GetWorker returns the worker with the given ID, or store.ErrNotFound.

func (*Store) LatestTaskAttempt

func (s *Store) LatestTaskAttempt(_ context.Context, taskID string) (store.TaskAttempt, error)

LatestTaskAttempt returns the attempt with the highest AttemptNumber for the given task, or store.ErrNotFound if no attempts exist.

func (*Store) LeaseReadyTask

func (s *Store) LeaseReadyTask(_ context.Context, taskID, workerID string, now time.Time) (bool, error)

LeaseReadyTask implements store.TaskStore.

func (*Store) ListAuditEntries

func (s *Store) ListAuditEntries(_ context.Context, entityType, entityID string) ([]store.AuditEntry, error)

ListAuditEntries returns all audit entries for the given entity, ordered by CreatedAt ascending. Pass empty strings to list all entries.

func (*Store) ListBlockedJobs added in v0.2.0

func (s *Store) ListBlockedJobs(_ context.Context) ([]store.Job, error)

ListBlockedJobs returns every job currently in store.JobStatusBlocked.

func (*Store) ListComputeLocations added in v0.2.0

func (s *Store) ListComputeLocations(_ context.Context) ([]store.ComputeLocation, error)

ListComputeLocations returns all locations ordered by name.

func (*Store) ListDependents added in v0.2.0

func (s *Store) ListDependents(_ context.Context, upstreamJobID string) ([]string, error)

ListDependents returns the IDs of jobs that declared a dependency on upstreamJobID, ordered by dependent job ID.

func (*Store) ListFarms

func (s *Store) ListFarms(_ context.Context) ([]store.Farm, error)

ListFarms returns all farms ordered by name.

func (*Store) ListJobDependencyIDs added in v0.2.0

func (s *Store) ListJobDependencyIDs(_ context.Context, jobID string) ([]string, error)

ListJobDependencyIDs returns the upstream job IDs jobID waits on, ordered by upstream job ID (matching the SQLite implementation's ORDER BY).

func (*Store) ListJobs

func (s *Store) ListJobs(_ context.Context, opts store.ListJobsOptions) (store.Page[store.Job], error)

ListJobs returns a paginated, filtered, and sorted page of jobs matching opts.

func (*Store) ListProducts added in v0.2.0

func (s *Store) ListProducts(_ context.Context) ([]store.Product, error)

ListProducts returns all products ordered by name.

func (*Store) ListQueues

func (s *Store) ListQueues(_ context.Context, opts store.ListQueuesOptions) (store.Page[store.Queue], error)

ListQueues returns a paginated, filtered, and sorted page of queues matching opts.

func (*Store) ListReadyTasks

func (s *Store) ListReadyTasks(_ context.Context, farmID string, now time.Time, limit int) ([]store.Task, error)

ListReadyTasks returns up to limit tasks in store.TaskStatusReady that belong to non-paused queues within the given farm, excluding tasks still backing off (RetryAfter after now) and tasks whose job is paused or terminal, ordered by job priority descending then CreatedAt ascending.

func (*Store) ListStaleWorkers

func (s *Store) ListStaleWorkers(_ context.Context, before time.Time) ([]store.Worker, error)

ListStaleWorkers returns workers whose last heartbeat is older than before and whose status is store.WorkerStatusOnline.

func (*Store) ListSteps

func (s *Store) ListSteps(_ context.Context, jobID string) ([]store.Step, error)

ListSteps returns all steps for the given job, ordered by StepOrder ascending.

func (*Store) ListStorageLocations

func (s *Store) ListStorageLocations(_ context.Context) ([]store.StorageLocation, error)

ListStorageLocations returns all locations ordered by name.

func (*Store) ListTaskAttempts

func (s *Store) ListTaskAttempts(_ context.Context, taskID string) ([]store.TaskAttempt, error)

ListTaskAttempts returns all attempts for the given task, ordered by AttemptNumber ascending.

func (*Store) ListTaskLogs

func (s *Store) ListTaskLogs(_ context.Context, attemptID string, afterNATSSeq int64, limit int) ([]store.TaskLog, error)

ListTaskLogs implements store.TaskLogStore. Returns chunks for attemptID with NATSSeq > afterNATSSeq, sorted by NATSSeq ascending.

func (*Store) ListTasks

func (s *Store) ListTasks(_ context.Context, opts store.ListTasksOptions) (store.Page[store.Task], error)

ListTasks returns a paginated, filtered, and sorted page of tasks matching opts.

func (*Store) ListUsagePoolUtilization

func (s *Store) ListUsagePoolUtilization(_ context.Context) ([]store.UsagePoolUtilization, error)

ListUsagePoolUtilization returns all pools ordered by name, each paired with its current number of active claims.

func (*Store) ListUsagePools

func (s *Store) ListUsagePools(_ context.Context) ([]store.UsagePool, error)

ListUsagePools returns all pools ordered by name.

func (*Store) ListWorkers

func (s *Store) ListWorkers(_ context.Context, opts store.ListWorkersOptions) (store.Page[store.Worker], error)

ListWorkers returns a paginated, filtered, and sorted page of workers matching opts.

func (*Store) ParkJob added in v0.2.0

func (s *Store) ParkJob(_ context.Context, jobID, reason string, now time.Time) error

ParkJob implements store.JobStore. It transitions the job to store.JobStatusPaused and records reason, but only while the job is non-terminal; a terminal job (completed/failed/canceled) is a legitimate no-op.

func (*Store) ReclaimStaleAssignedTasks

func (s *Store) ReclaimStaleAssignedTasks(_ context.Context, cutoff time.Time) ([]store.Task, error)

ReclaimStaleAssignedTasks resets tasks stuck in store.TaskStatusAssigned with an AssignedAt older than cutoff back to store.TaskStatusReady and returns the reclaimed tasks (carrying their pre-reset assigned_worker_id).

func (*Store) ReclaimWorkerTasks

func (s *Store) ReclaimWorkerTasks(_ context.Context, workerID string) (int, error)

ReclaimWorkerTasks resets assigned/running tasks for the given worker back to store.TaskStatusReady and returns the count of tasks reclaimed.

func (*Store) RecordTaskFailure added in v0.2.0

func (s *Store) RecordTaskFailure(
	_ context.Context,
	attemptID, taskID string,
	exitCode *int,
	sessionID, message string,
	now time.Time,
) (taskFailed, jobFailed int, firstClose bool, err error)

RecordTaskFailure implements store.TaskStore. Under the store lock it closes the attempt as failed and increments the task's and job's FailedAttempts counters ONLY when the attempt is still running (the first delivery of the failure). A redelivery — whose attempt is already terminal, or whose attempt is unknown — does not re-count; it returns the current counters so the caller's retry/park decision is stable across redeliveries.

func (*Store) RegisterWorker

func (s *Store) RegisterWorker(_ context.Context, worker store.Worker) (store.Worker, error)

RegisterWorker inserts or replaces the worker record for the given ID. If the worker ID already exists its record is updated in full.

func (*Store) ReleaseAttemptClaims

func (s *Store) ReleaseAttemptClaims(_ context.Context, taskAttemptID string, releasedAt time.Time) (int, error)

ReleaseAttemptClaims sets ReleasedAt on every active claim for the given taskAttemptID and returns the number of claims released.

func (*Store) ReleaseClaim

func (s *Store) ReleaseClaim(_ context.Context, id string, releasedAt time.Time) error

ReleaseClaim sets ReleasedAt on the claim with the given ID, marking it as no longer active. Returns store.ErrNotFound if it does not exist.

func (*Store) ReleaseJobClaims

func (s *Store) ReleaseJobClaims(_ context.Context, jobID string, releasedAt time.Time) (int, error)

ReleaseJobClaims sets ReleasedAt on every active claim held by any attempt for tasks belonging to the given job. Returns the number released.

func (*Store) RequeueTaskForRetry added in v0.2.0

func (s *Store) RequeueTaskForRetry(_ context.Context, taskID string, retryAfter, now time.Time) (bool, error)

RequeueTaskForRetry implements store.TaskStore. It returns the task to store.TaskStatusReady, clears its worker assignment, and stamps RetryAfter. Guarded to assigned/running; anything else (including a missing task) is a legitimate no-op reported as false.

func (*Store) Reset

func (s *Store) Reset()

Reset reinitializes all maps to empty. Convenience helper for tests that call t.Cleanup(s.Reset) rather than constructing a new fake per sub-test.

func (*Store) ResumeJob added in v0.2.0

func (s *Store) ResumeJob(_ context.Context, jobID string, now time.Time) error

ResumeJob implements store.JobStore. It transitions a paused job back to store.JobStatusPending; an auto-parked job (non-empty ParkReason) also has its ParkReason cleared and FailedAttempts reset. A job that is no longer paused is a legitimate no-op.

func (*Store) RetryTasks

func (s *Store) RetryTasks(_ context.Context, jobID string, taskIDs []string, now time.Time) ([]store.Task, error)

RetryTasks reverts failed/canceled tasks (and their terminal steps and the terminal job) to pending. See store.TaskStore.RetryTasks.

func (*Store) SetTaskFailureReason added in v0.2.0

func (s *Store) SetTaskFailureReason(_ context.Context, id, reason string) error

SetTaskFailureReason implements store.TaskStore.

func (*Store) SetTaskFailureReasonIfEmpty added in v0.2.0

func (s *Store) SetTaskFailureReasonIfEmpty(_ context.Context, id, reason string) error

SetTaskFailureReasonIfEmpty implements store.TaskStore. It writes the reason only when the task currently has none; an unknown task or one that already carries a reason is a legitimate no-op, not an error.

func (*Store) SetTaskUnschedulableReason added in v0.2.0

func (s *Store) SetTaskUnschedulableReason(_ context.Context, id, reason string) error

SetTaskUnschedulableReason implements store.TaskStore.

func (*Store) TerminateWorkerAttempts

func (s *Store) TerminateWorkerAttempts(_ context.Context, workerID string, status store.AttemptStatus, endedAt time.Time) (int, error)

TerminateWorkerAttempts marks all running attempts for tasks currently assigned to workerID as the given terminal status with the supplied end time.

func (*Store) TransitionStepPendingTasks

func (s *Store) TransitionStepPendingTasks(_ context.Context, stepID string, to store.TaskStatus, failureReason string) ([]store.Task, error)

TransitionStepPendingTasks transitions every pending task of the step to `to`, updates UpdatedAt, stamps a non-empty failureReason on tasks that carry none, and returns the affected tasks.

func (*Store) TryClaimSlots

func (s *Store) TryClaimSlots(
	_ context.Context,
	taskAttemptID string,
	claims []store.UsagePoolClaim,
	claimedAt time.Time,
) error

TryClaimSlots atomically checks pool capacity and creates claim records for each claim. The fake implementation holds the mutex for the duration of the check-and-insert, mirroring the transactional semantics of the SQLite implementation.

func (*Store) UpdateComputeLocation added in v0.2.0

func (s *Store) UpdateComputeLocation(_ context.Context, loc store.ComputeLocation) (store.ComputeLocation, error)

UpdateComputeLocation replaces the mutable fields of an existing location and updates UpdatedAt. Returns store.ErrNotFound or store.ErrConflict.

func (*Store) UpdateFarm

func (s *Store) UpdateFarm(_ context.Context, farm store.Farm) (store.Farm, error)

UpdateFarm replaces the mutable fields (Name, Description, MaxConcurrentTasks) of an existing farm and updates UpdatedAt. Returns store.ErrNotFound if the farm does not exist, or store.ErrConflict if the new name is already taken.

func (*Store) UpdateJob

func (s *Store) UpdateJob(_ context.Context, job store.Job) (store.Job, error)

UpdateJob replaces only the mutable user-settable fields of an existing job. status, started_at, completed_at, and parameters are preserved from the stored record to match the sqlite implementation which excludes those columns. parameters is persisted at submission time and is not mutable via UpdateJob.

func (*Store) UpdateJobStatus

func (s *Store) UpdateJobStatus(_ context.Context, id string, status store.JobStatus) error

UpdateJobStatus transitions a job to a new status and updates UpdatedAt. If the new status is store.JobStatusRunning and StartedAt is nil, StartedAt is set to the current time. Terminal statuses set CompletedAt.

func (*Store) UpdateProduct added in v0.2.0

func (s *Store) UpdateProduct(_ context.Context, p store.Product) (store.Product, error)

UpdateProduct replaces mutable fields of the product with p.Name.

func (*Store) UpdateQueue

func (s *Store) UpdateQueue(_ context.Context, queue store.Queue) (store.Queue, error)

UpdateQueue replaces the mutable fields of an existing queue and updates UpdatedAt. Returns store.ErrNotFound or store.ErrConflict as appropriate.

func (*Store) UpdateStepStatus

func (s *Store) UpdateStepStatus(_ context.Context, id string, status store.StepStatus) error

UpdateStepStatus transitions a step to a new status and updates UpdatedAt.

func (*Store) UpdateStorageLocation

func (s *Store) UpdateStorageLocation(_ context.Context, loc store.StorageLocation) (store.StorageLocation, error)

UpdateStorageLocation replaces the mutable fields of an existing location and updates UpdatedAt. Returns store.ErrNotFound or store.ErrConflict.

func (*Store) UpdateTaskAttempt

func (s *Store) UpdateTaskAttempt(_ context.Context, attempt store.TaskAttempt) (store.TaskAttempt, error)

UpdateTaskAttempt replaces the mutable fields of an existing attempt (Status, ExitCode, EndedAt, and SessionID/Message if non-empty).

func (*Store) UpdateTaskStatus

func (s *Store) UpdateTaskStatus(_ context.Context, id string, status store.TaskStatus) error

UpdateTaskStatus transitions a task to a new status and updates UpdatedAt. unschedulable_reason is only meaningful while a task is ready (set by the scheduler sweep), so it is cleared here regardless of the destination status — harmless when it was already empty.

func (*Store) UpdateUsagePool

func (s *Store) UpdateUsagePool(_ context.Context, pool store.UsagePool) (store.UsagePool, error)

UpdateUsagePool replaces the mutable fields of an existing pool and updates UpdatedAt. Returns store.ErrNotFound or store.ErrConflict.

func (*Store) UpdateWorker

func (s *Store) UpdateWorker(_ context.Context, worker store.Worker) (store.Worker, error)

UpdateWorker replaces the mutable capability fields of an existing worker (everything except ID and RegisteredAt) and updates UpdatedAt.

func (*Store) UpdateWorkerHeartbeat

func (s *Store) UpdateWorkerHeartbeat(_ context.Context, id string, at time.Time) error

UpdateWorkerHeartbeat records the most recent heartbeat time for the given worker.

func (*Store) UpdateWorkerStatus

func (s *Store) UpdateWorkerStatus(_ context.Context, id string, status store.WorkerStatus) error

UpdateWorkerStatus sets the status of the worker and updates UpdatedAt.

Jump to

Keyboard shortcuts

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