Help us shape the future of Go! Take the 2026 Go Developer Survey

memory

package
v1.9.3 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package memory implements an in-memory store for unit testing. Zero external dependencies.

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 a fully in-memory implementation of store.Store. Safe for concurrent access. Intended for unit testing and development.

func New

func New() *Store

New returns a new empty Store.

func (*Store) AbortBuildRetirement

func (m *Store) AbortBuildRetirement(ctx context.Context, r durable.BuildRetirementRequest) (durable.LifecycleReceipt, error)

func (*Store) AbortQueryRuntimeRemoval

func (m *Store) AbortQueryRuntimeRemoval(ctx context.Context, r durable.AbortQueryRemovalRequest) (durable.LifecycleReceipt, error)

func (*Store) AckEvent

func (m *Store) AckEvent(_ context.Context, eventID id.EventID) error

AckEvent acknowledges an event, marking it as consumed.

func (*Store) AcknowledgeDelivery

func (m *Store) AcknowledgeDelivery(ctx context.Context, t durable.DeliveryToken, r durable.SinkReceipt) error

func (*Store) AcquireCronLock

func (m *Store) AcquireCronLock(_ context.Context, entryID id.CronID, workerID id.WorkerID, ttl time.Duration) (bool, error)

AcquireCronLock attempts to acquire a distributed lock for a cron entry.

func (*Store) AcquireLeadership

func (m *Store) AcquireLeadership(_ context.Context, workerID id.WorkerID, ttl time.Duration) (bool, error)

AcquireLeadership attempts to become the cluster leader.

func (*Store) AppendSecurityAudit

func (m *Store) AppendSecurityAudit(ctx context.Context, a durable.SecurityAudit) (durable.Delivery, error)

func (*Store) ApplyExecutionTimeout

func (m *Store) ApplyExecutionTimeout(ctx context.Context, r durable.ExecutionTimeoutRequest) (durable.Receipt, error)

func (*Store) BeginBuildRetirement

func (m *Store) BeginBuildRetirement(ctx context.Context, r durable.BuildRetirementRequest) (durable.LifecycleReceipt, error)

func (*Store) BeginLegacyAttempt

func (m *Store) BeginLegacyAttempt(ctx context.Context, a durable.SecurityAudit) (durable.LegacyAttempt, error)

func (*Store) BeginQueryRuntimeRemoval

func (m *Store) BeginQueryRuntimeRemoval(ctx context.Context, r durable.BeginQueryRemovalRequest) (durable.LifecycleReceipt, error)

func (*Store) BindQueryRemovalCommit

BindQueryRemovalCommit records one external permission after fresh native checks.

func (*Store) BlockDelivery

func (m *Store) BlockDelivery(ctx context.Context, t durable.DeliveryToken) error

func (*Store) CheckQueryRemovalCommit

CheckQueryRemovalCommit reports saved commitment and current guard observations.

func (*Store) CheckQueryRuntimeRemoval

func (m *Store) CheckQueryRuntimeRemoval(ctx context.Context, f durable.QueryRemovalFence) (durable.QueryRemovalFacts, error)

func (*Store) ClaimChildDelivery

ClaimChildDelivery polls messages even when their source execution has closed.

func (*Store) ClaimDeliveries

func (m *Store) ClaimDeliveries(ctx context.Context, r durable.DeliveryClaim) ([]durable.DeliveryRecord, error)

func (*Store) ClaimExecutionTimeout

ClaimExecutionTimeout grants an expired run independently of its tasks/build.

func (*Store) ClaimReplay

func (m *Store) ClaimReplay(_ context.Context, entryID id.DLQID, jobID id.JobID) error

ClaimReplay marks an unreplayed entry replayed by jobID. The check and the write happen under one lock, so of two concurrent claims exactly one wins.

func (*Store) ClaimTask

func (m *Store) ClaimTask(ctx context.Context, r durable.ClaimRequest) (*durable.Task, error)

ClaimTask grants or reclaims one eligible task using the store's clock.

func (*Store) ClaimTimeoutTask

func (m *Store) ClaimTimeoutTask(ctx context.Context, r durable.TimeoutClaimRequest) (*durable.Task, error)

ClaimTimeoutTask fences execution and grants independent timeout processing.

func (*Store) Close

func (m *Store) Close() error

Close is a no-op for the memory store.

func (*Store) CloseQueryRemovalGuard

CloseQueryRemovalGuard releases pins only after authenticated complete cutoff.

func (*Store) CommitTransition

func (m *Store) CommitTransition(ctx context.Context, r durable.CommitRequest) (durable.Receipt, error)

func (*Store) CompleteLegacyAttempt

func (m *Store) CompleteLegacyAttempt(ctx context.Context, o durable.LegacyOutcome) error

func (*Store) CountDLQ

func (m *Store) CountDLQ(_ context.Context) (int64, error)

CountDLQ returns the total number of entries in the dead letter queue.

func (*Store) CountDLQEntries

func (m *Store) CountDLQEntries(_ context.Context, opts dlq.CountOpts) (int64, error)

CountDLQEntries counts dead letter entries under the given filters.

func (*Store) CountJobs

func (m *Store) CountJobs(_ context.Context, opts job.CountOpts) (int64, error)

CountJobs returns the number of jobs matching the given options.

func (*Store) CountRuns

func (m *Store) CountRuns(_ context.Context, opts workflow.CountRunsOpts) (int64, error)

CountRuns counts workflow runs by state and exact name.

func (*Store) CreateArtifact

func (s *Store) CreateArtifact(_ context.Context, a *artifact.Artifact, link *artifact.Link) error

CreateArtifact inserts an artifact and, when link is non-nil, its first link atomically under the store lock.

func (*Store) CreateRun

func (m *Store) CreateRun(_ context.Context, run *workflow.Run) error

CreateRun persists a new workflow run.

func (*Store) DeleteCheckpointsAfter

func (m *Store) DeleteCheckpointsAfter(_ context.Context, runID id.RunID, afterStep string) error

DeleteCheckpointsAfter removes all checkpoints created after the given step name (by creation order). Used for workflow replay.

func (*Store) DeleteCron

func (m *Store) DeleteCron(_ context.Context, entryID id.CronID) error

DeleteCron removes a cron entry by ID.

func (*Store) DeleteDLQ

func (m *Store) DeleteDLQ(_ context.Context, entryID id.DLQID) error

DeleteDLQ removes one entry.

func (*Store) DeleteJob

func (m *Store) DeleteJob(_ context.Context, jobID id.JobID) error

DeleteJob removes a job by ID.

func (*Store) DeleteStaleWorkers

func (m *Store) DeleteStaleWorkers(_ context.Context, threshold time.Duration) (int64, error)

DeleteStaleWorkers removes worker entries whose last-seen timestamp is older than the given threshold. Returns the number of entries removed.

func (*Store) DeliveryStatus

func (*Store) DequeueJobs

func (m *Store) DequeueJobs(_ context.Context, opts job.DequeueOpts) ([]*job.Job, error)

DequeueJobs atomically claims up to opts.Limit ready jobs from opts.Queues that fit opts, sets them to running, and returns them ordered by priority descending, then locality-preferred first, then RunAt ascending.

A non-positive Limit claims nothing: a worker computing zero free slots must claim zero jobs, matching the SQL backends' `LIMIT 0` behavior rather than reading zero as "unlimited". The fit predicate itself is job.DequeueOpts.Allows / Less, not reimplemented here, so this store stays the reference the SQL backends are checked against.

When opts.Grants() the claim also grants a lease, under the one write lock that already performs the claim. When it does not, the claim writes a running job with no lease at all, which is a supported shape rather than a broken one. Such a job is not invisible to ReclaimExpiredLeases: job.Lease.IsExpired still reports false for its zero expiry, but reclaim adopts it once it has gone silent for job.UnleasedReclaimGrace, so abandoning one no longer strands it for the life of the process. See job.DequeueOpts.LeaseUntil.

func (*Store) DeregisterWorker

func (m *Store) DeregisterWorker(_ context.Context, workerID id.WorkerID) error

DeregisterWorker removes a worker from the cluster registry.

func (*Store) EnqueueJob

func (m *Store) EnqueueJob(_ context.Context, j *job.Job) error

EnqueueJob persists a new job in pending state.

func (*Store) FinalizeBuildRetirement

func (m *Store) FinalizeBuildRetirement(ctx context.Context, r durable.BuildRetirementRequest) (durable.LifecycleReceipt, error)

func (*Store) FindArtifactByKey

func (s *Store) FindArtifactByKey(_ context.Context, backend, bucket, key string) (*artifact.Artifact, error)

FindArtifactByKey retrieves an artifact by its storage coordinates.

func (*Store) FindLinkByName

func (s *Store) FindLinkByName(_ context.Context, owner artifact.OwnerRef, name string) (*artifact.Link, error)

FindLinkByName returns the link for an owner and name with the highest attempt number, breaking ties by CreatedAt descending — see the artifact.Store doc comment for why ties happen and what the tie-break does and does not fix.

func (*Store) FinishQueryRuntimeRemoval

func (m *Store) FinishQueryRuntimeRemoval(ctx context.Context, r durable.FinishQueryRemovalRequest) (durable.LifecycleReceipt, error)

func (*Store) GetArtifact

func (s *Store) GetArtifact(_ context.Context, artifactID id.ArtifactID) (*artifact.Artifact, error)

GetArtifact retrieves an artifact by ID, excluding soft-deleted ones.

func (*Store) GetArtifactRecord

func (s *Store) GetArtifactRecord(_ context.Context, artifactID id.ArtifactID) (*artifact.Artifact, error)

GetArtifactRecord returns detached metadata even after soft deletion.

func (*Store) GetCheckpoint

func (m *Store) GetCheckpoint(_ context.Context, runID id.RunID, stepName string) ([]byte, error)

GetCheckpoint retrieves checkpoint data for a specific workflow step.

func (*Store) GetChildDelivery

func (m *Store) GetChildDelivery(ctx context.Context, source durable.Key, id string) (durable.ChildDelivery, error)

GetChildDelivery returns an isolated view including its final disposition.

func (*Store) GetChildExecution

func (m *Store) GetChildExecution(ctx context.Context, parent durable.Key, commandID string) (durable.ChildExecution, error)

GetChildExecution reads one parent's immutable child identity and current state.

func (*Store) GetCron

func (m *Store) GetCron(_ context.Context, entryID id.CronID) (*cron.Entry, error)

GetCron retrieves a cron entry by ID.

func (*Store) GetDLQ

func (m *Store) GetDLQ(_ context.Context, entryID id.DLQID) (*dlq.Entry, error)

GetDLQ retrieves a DLQ entry by ID.

func (*Store) GetDLQByJobID

func (m *Store) GetDLQByJobID(_ context.Context, jobID id.JobID) (*dlq.Entry, error)

GetDLQByJobID returns the newest entry, by ID, for a failed job.

func (*Store) GetExecution

func (m *Store) GetExecution(ctx context.Context, key durable.Key) (durable.Execution, error)

GetExecution returns a copy of the namespace-qualified execution.

func (*Store) GetJob

func (m *Store) GetJob(_ context.Context, jobID id.JobID) (*job.Job, error)

GetJob retrieves a job by ID.

func (*Store) GetLeader

func (m *Store) GetLeader(_ context.Context) (*cluster.Worker, error)

GetLeader returns the current cluster leader, or nil if there is no leader.

func (*Store) GetNamespace

func (m *Store) GetNamespace(ctx context.Context, installation, namespace string) (durable.NamespaceRecord, error)

func (*Store) GetParentExecution

func (m *Store) GetParentExecution(ctx context.Context, child durable.Key) (durable.ChildExecution, error)

GetParentExecution reads a child's unique original parent relationship.

func (*Store) GetRun

func (m *Store) GetRun(_ context.Context, runID id.RunID) (*workflow.Run, error)

GetRun retrieves a workflow run by ID.

func (*Store) GetTask

func (m *Store) GetTask(ctx context.Context, key durable.Key, taskID string) (durable.Task, error)

GetTask returns a copy of a pending or completed task in one execution.

func (*Store) GetWorker

func (m *Store) GetWorker(_ context.Context, workerID id.WorkerID) (*cluster.Worker, error)

GetWorker returns a copy of one registered worker.

func (*Store) GetWorkflowTaskDeferral

func (m *Store) GetWorkflowTaskDeferral(ctx context.Context, key durable.Key, taskID string) (durable.WorkflowTaskDeferral, error)

func (*Store) HeartbeatJob

func (m *Store) HeartbeatJob(_ context.Context, jobID id.JobID, _ id.WorkerID) error

HeartbeatJob updates the heartbeat timestamp for a running job.

func (*Store) HeartbeatWorker

func (m *Store) HeartbeatWorker(_ context.Context, workerID id.WorkerID) error

HeartbeatWorker updates the last-seen timestamp for a worker.

func (*Store) InspectBuildLifecycle

func (m *Store) InspectBuildLifecycle(ctx context.Context, target durable.BuildTarget) (durable.BuildLifecycleFacts, error)

func (*Store) InspectCompatibility

func (m *Store) InspectCompatibility(ctx context.Context, target durable.NamespaceTarget) (durable.CompatibilityFacts, error)

func (*Store) InspectQueryRetention

func (m *Store) InspectQueryRetention(ctx context.Context, target durable.BuildTarget) (durable.QueryRetentionFacts, error)

func (*Store) LinkArtifact

func (s *Store) LinkArtifact(_ context.Context, link *artifact.Link) error

LinkArtifact records that an owner references an artifact. Linking the same tuple twice is a no-op.

func (*Store) ListArtifacts

func (s *Store) ListArtifacts(_ context.Context, opts artifact.ListOpts) ([]*artifact.Artifact, error)

ListArtifacts returns artifacts matching the given options, newest first.

func (*Store) ListArtifactsByOwner

func (s *Store) ListArtifactsByOwner(
	_ context.Context,
	owner artifact.OwnerRef,
	role artifact.Role,
) ([]*artifact.Artifact, error)

ListArtifactsByOwner returns the artifacts linked to an owner, optionally filtered by role.

func (*Store) ListArtifactsPage

func (m *Store) ListArtifactsPage(_ context.Context, opts artifact.PageOpts) (artifact.Page, error)

ListArtifactsPage returns artifacts newest first by ID, filtered and paged.

func (*Store) ListCheckpoints

func (m *Store) ListCheckpoints(_ context.Context, runID id.RunID) ([]*workflow.Checkpoint, error)

ListCheckpoints returns all checkpoints for a workflow run.

func (*Store) ListChildDeliveries

func (m *Store) ListChildDeliveries(ctx context.Context, source durable.Key, after string, limit int) ([]durable.ChildDelivery, error)

ListChildDeliveries pages by exclusive delivery ID, including completed rows.

func (*Store) ListChildExecutions

func (m *Store) ListChildExecutions(ctx context.Context, parent durable.Key, after string, limit int) ([]durable.ChildExecution, error)

ListChildExecutions pages by command ID, with an exclusive cursor.

func (*Store) ListChildRuns

func (m *Store) ListChildRuns(_ context.Context, parentRunID id.RunID) ([]*workflow.Run, error)

ListChildRuns returns all child workflow runs for a parent.

func (*Store) ListCrons

func (m *Store) ListCrons(_ context.Context) ([]*cron.Entry, error)

ListCrons returns all cron entries.

func (*Store) ListDLQ

func (m *Store) ListDLQ(_ context.Context, opts dlq.ListOpts) ([]*dlq.Entry, error)

ListDLQ returns DLQ entries matching the given options.

func (*Store) ListDLQPage

func (m *Store) ListDLQPage(_ context.Context, opts dlq.PageOpts) (dlq.Page, error)

ListDLQPage returns dead letter entries newest first by ID, filtered and paged.

func (*Store) ListExecutions

func (m *Store) ListExecutions(ctx context.Context, r durable.ExecutionList) ([]durable.Execution, string, error)

func (*Store) ListJobUsage

func (s *Store) ListJobUsage(_ context.Context, opts job.UsageListOpts) ([]*job.Usage, error)

ListJobUsage returns recorded attempts, most recent first.

func (*Store) ListJobs

func (m *Store) ListJobs(_ context.Context, opts job.ListJobsOpts) (job.Page, error)

ListJobs returns jobs newest first by ID, filtered and paged.

func (*Store) ListJobsByState

func (m *Store) ListJobsByState(_ context.Context, state job.State, opts job.ListOpts) ([]*job.Job, error)

ListJobsByState returns jobs matching the given state.

func (s *Store) ListLinks(_ context.Context, owner artifact.OwnerRef) ([]*artifact.Link, error)

ListLinks returns every link belonging to the given owner.

func (*Store) ListNamespaces

func (m *Store) ListNamespaces(ctx context.Context, r durable.NamespaceList) ([]durable.NamespaceRecord, error)

func (*Store) ListPurgeable

func (s *Store) ListPurgeable(_ context.Context, grace time.Duration, limit int) ([]*artifact.Artifact, error)

ListPurgeable returns soft-deleted artifacts older than grace.

func (*Store) ListQueryRuntimes

func (m *Store) ListQueryRuntimes(ctx context.Context, r durable.QueryRuntimeList) (durable.QueryRuntimePage, error)

func (*Store) ListRuns

func (m *Store) ListRuns(_ context.Context, opts workflow.ListOpts) ([]*workflow.Run, error)

ListRuns returns workflow runs matching the given options.

func (*Store) ListRunsPage

func (m *Store) ListRunsPage(_ context.Context, opts workflow.ListRunsPageOpts) (workflow.RunPage, error)

ListRunsPage returns workflow runs newest first by ID, filtered and paged.

func (*Store) ListTasks

func (m *Store) ListTasks(ctx context.Context, r durable.TaskList) ([]durable.Task, string, error)

func (*Store) ListWorkers

func (m *Store) ListWorkers(_ context.Context) ([]*cluster.Worker, error)

ListWorkers returns all registered workers.

func (*Store) LookupLifecycleReceipt

func (m *Store) LookupLifecycleReceipt(ctx context.Context, q durable.LifecycleReceiptLookup) (durable.LifecycleReceipt, error)

func (*Store) LookupQueryRemovalGuardReceipt

LookupQueryRemovalGuardReceipt recovers one immutable command before host probes.

func (*Store) LookupQueryRemovalRevalidation

LookupQueryRemovalRevalidation recovers authenticated material without renewal.

func (*Store) LookupReceipt

func (m *Store) LookupReceipt(ctx context.Context, r durable.ReceiptRequest) (durable.Receipt, bool, error)

LookupReceipt returns the original result only for the exact accepted intent.

func (*Store) Migrate

func (m *Store) Migrate(_ context.Context) error

Migrate is a no-op for the memory store.

func (*Store) Ping

func (m *Store) Ping(_ context.Context) error

Ping always succeeds for the memory store.

func (*Store) PublishEvent

func (m *Store) PublishEvent(_ context.Context, evt *event.Event) error

PublishEvent persists a new event.

func (*Store) PurgeArtifact

func (s *Store) PurgeArtifact(_ context.Context, artifactID id.ArtifactID) error

PurgeArtifact hard-deletes an artifact and its links.

func (*Store) PurgeDLQ

func (m *Store) PurgeDLQ(_ context.Context, before time.Time) (int64, error)

PurgeDLQ removes DLQ entries with FailedAt before the given time.

func (*Store) PurgeJobUsage

func (s *Store) PurgeJobUsage(_ context.Context, before time.Time, limit int) (int64, error)

PurgeJobUsage deletes records older than before, up to limit rows.

func (*Store) PushDLQ

func (m *Store) PushDLQ(_ context.Context, entry *dlq.Entry) error

PushDLQ adds a failed job entry to the dead letter queue. An ID that is already there is refused with dispatch.ErrDLQAlreadyExists rather than overwritten, which would silently drop a replay claim.

func (*Store) ReadBuildFacts

func (m *Store) ReadBuildFacts(ctx context.Context, namespace, build string) (durable.BuildFacts, error)

func (*Store) ReadDeliveryStatus

func (m *Store) ReadDeliveryStatus(ctx context.Context, r durable.ScopedDeliveryStatus) (durable.DeliveryStatus, error)

func (*Store) ReadHistory

func (m *Store) ReadHistory(ctx context.Context, key durable.Key, after int64, limit int) ([]durable.Event, error)

ReadHistory reads a bounded page after an exclusive sequence cursor.

func (*Store) ReapDeadWorkers

func (m *Store) ReapDeadWorkers(_ context.Context, threshold time.Duration) ([]*cluster.Worker, error)

ReapDeadWorkers returns workers whose last-seen timestamp is older than the given threshold.

func (*Store) ReapStaleJobs

func (m *Store) ReapStaleJobs(_ context.Context, threshold time.Duration) ([]*job.Job, error)

ReapStaleJobs returns running jobs whose last heartbeat — or, for jobs whose worker died before the first heartbeat, whose start time — is older than the given threshold.

func (*Store) ReclaimExpiredLeases

func (m *Store) ReclaimExpiredLeases(_ context.Context, limit int) ([]*job.Job, error)

ReclaimExpiredLeases returns expired-lease jobs to pending, fencing their previous holders.

A non-positive limit claims nothing, matching DequeueOpts.Limit's behavior rather than reading zero or negative as unlimited.

func (*Store) RecordHeartbeat

func (m *Store) RecordHeartbeat(ctx context.Context, r durable.HeartbeatRequest) (durable.Receipt, error)

func (*Store) RecordJobUsage

func (s *Store) RecordJobUsage(_ context.Context, u *job.Usage) error

RecordJobUsage persists one attempt's measurements.

func (*Store) RecordQueryRuntimeVerification

func (m *Store) RecordQueryRuntimeVerification(ctx context.Context, r durable.VerifyQueryRuntimeRequest) (durable.LifecycleReceipt, error)

func (*Store) RegisterBuild

func (*Store) RegisterCron

func (m *Store) RegisterCron(_ context.Context, entry *cron.Entry) error

RegisterCron persists a new cron entry. Returns an error if the name already exists.

func (*Store) RegisterNamespace

func (m *Store) RegisterNamespace(ctx context.Context, c durable.NamespaceConfig) (durable.NamespaceRecord, error)

func (*Store) RegisterWorker

func (m *Store) RegisterWorker(_ context.Context, w *cluster.Worker) error

RegisterWorker adds a worker to the cluster registry, replacing any existing entry with the same ID.

func (*Store) ReleaseCronLock

func (m *Store) ReleaseCronLock(_ context.Context, entryID id.CronID, workerID id.WorkerID) error

ReleaseCronLock releases the distributed lock for a cron entry.

func (*Store) ReleaseReplay

func (m *Store) ReleaseReplay(_ context.Context, entryID id.DLQID, jobID id.JobID) error

ReleaseReplay undoes a claim, but only the one jobID made.

func (*Store) RenewDelivery

func (m *Store) RenewDelivery(ctx context.Context, t durable.DeliveryToken, ttl time.Duration) (time.Time, error)

func (*Store) RenewLeadership

func (m *Store) RenewLeadership(_ context.Context, workerID id.WorkerID, ttl time.Duration) (bool, error)

RenewLeadership extends the leader's hold.

func (*Store) RenewLease

func (m *Store) RenewLease(
	_ context.Context,
	jobID id.JobID,
	workerID id.WorkerID,
	epoch int,
	leaseUntil time.Time,
) error

RenewLease extends the lease only if the caller still holds it.

func (*Store) RenewTask

func (m *Store) RenewTask(ctx context.Context, key durable.Key, token durable.TaskToken, ttl time.Duration) (time.Time, error)

RenewTask extends only a current, unexpired task lease.

func (*Store) ReopenRun

func (m *Store) ReopenRun(_ context.Context, runID id.RunID, expectedGeneration int64) error

ReopenRun moves a finished run back to running. The check and the write happen under one lock, so of two concurrent reopens exactly one wins.

func (*Store) ReplayDLQ

func (m *Store) ReplayDLQ(_ context.Context, entryID id.DLQID) error

ReplayDLQ marks a DLQ entry as replayed.

func (*Store) RequestWorkerDrain

func (m *Store) RequestWorkerDrain(ctx context.Context, r durable.WorkerDrainRequest) (durable.LifecycleReceipt, error)

func (*Store) ResolveExecution

func (m *Store) ResolveExecution(ctx context.Context, r durable.ExecutionTarget) (durable.Execution, error)

ResolveExecution copies one execution snapshot under the store read lock.

func (*Store) RetryDelivery

func (m *Store) RetryDelivery(ctx context.Context, r durable.DeliveryRetry) error

func (*Store) RevalidateQueryRuntimeRemoval

RevalidateQueryRuntimeRemoval atomically protects all selected associations.

func (*Store) SaveCheckpoint

func (m *Store) SaveCheckpoint(_ context.Context, runID id.RunID, stepName string, data []byte) error

SaveCheckpoint persists checkpoint data for a workflow step.

func (*Store) SetCronEnabled

func (m *Store) SetCronEnabled(_ context.Context, entryID id.CronID, enabled bool, nextRunAt *time.Time) error

SetCronEnabled sets enabled, and next_run_at when one is given.

func (*Store) SignalExecution

func (m *Store) SignalExecution(ctx context.Context, r durable.SignalRequest) (durable.SignalReceipt, error)

func (*Store) SignalWithStart

func (*Store) SignalWithStartOutcome

func (m *Store) SignalWithStartOutcome(ctx context.Context, r durable.SignalWithStartRequest) (durable.SignalStartOutcome, error)

SignalWithStartOutcome preserves acceptance provenance within the audited lock.

func (*Store) StartExecution

func (m *Store) StartExecution(ctx context.Context, r durable.StartRequest) (durable.Receipt, error)

func (*Store) SubscribeEvent

func (m *Store) SubscribeEvent(ctx context.Context, name string, timeout time.Duration) (*event.Event, error)

SubscribeEvent waits for an unacked event matching the given name. Poll-based: loops with 10ms sleep until an event is available or timeout.

func (*Store) SweepEphemeral

func (s *Store) SweepEphemeral(_ context.Context, opts artifact.SweepOpts) ([]*artifact.Artifact, error)

SweepEphemeral marks eligible ephemeral artifacts as deleted.

An artifact is eligible when every owner that links it is terminal and the retention window has elapsed since the last of them finished. The lifecycle guard is the first statement of the loop body and is written as a literal, mirroring the SQL backends.

func (*Store) SweepOrphans

func (s *Store) SweepOrphans(_ context.Context, cutoff time.Time, limit int) ([]*artifact.Artifact, error)

SweepOrphans marks ephemeral artifacts with no links at all that were created before the cutoff.

func (*Store) UnresolvedLegacyAttempts

func (m *Store) UnresolvedLegacyAttempts(ctx context.Context, r durable.LegacyAttemptList) ([]durable.LegacyAttempt, error)

func (*Store) UpdateArtifact

func (s *Store) UpdateArtifact(_ context.Context, a *artifact.Artifact) error

UpdateArtifact persists changes to size, hash, content type, and expiry. Lifecycle is deliberately not updatable.

func (*Store) UpdateCronEntry

func (m *Store) UpdateCronEntry(_ context.Context, entry *cron.Entry) error

UpdateCronEntry updates a cron entry (Enabled, NextRunAt, etc.).

func (*Store) UpdateCronLastRun

func (m *Store) UpdateCronLastRun(_ context.Context, entryID id.CronID, at time.Time) error

UpdateCronLastRun records when a cron entry last fired.

func (*Store) UpdateCronNextRun

func (m *Store) UpdateCronNextRun(_ context.Context, entryID id.CronID, nextRunAt time.Time) error

UpdateCronNextRun sets next_run_at and nothing else the scheduler does not own.

func (*Store) UpdateJob

func (m *Store) UpdateJob(_ context.Context, j *job.Job) error

UpdateJob persists changes to an existing job.

func (*Store) UpdateLeasedJob

func (m *Store) UpdateLeasedJob(_ context.Context, j *job.Job, workerID id.WorkerID, epoch int) error

UpdateLeasedJob persists j only while the caller still holds the lease — still running, still assigned to workerID, still at epoch. Otherwise it returns job.ErrLeaseLost and leaves the stored job untouched.

Only the business fields move. lease_epoch, lease_expires_at, worker_id, and heartbeat_at are copied from the CURRENTLY STORED job, never from j: j is the caller's stale snapshot, and every renewal since it was taken has pushed the real expiry forward. Overwriting that with j's copy would roll the winner's lease backwards even though the epoch check passed — see job.LeaseStore.UpdateLeasedJob.

func (*Store) UpdateRun

func (m *Store) UpdateRun(_ context.Context, run *workflow.Run) error

UpdateRun persists changes to an existing workflow run.

Jump to

Keyboard shortcuts

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