Documentation
¶
Index ¶
- Constants
- Variables
- func AssignArtifactKey(art Artifact, key ArtifactKey)
- func IsAppError(err error) bool
- func IsConflict(err error) bool
- func IsExecutionLeaseLost(err error) bool
- func IsExecutionSuspended(err error) bool
- func IsExistingJobMismatch(err error) bool
- func IsSystemError(err error) bool
- func NewSystemError(payload SystemErrorPayload) error
- func NewTimeoutError(kind string, after time.Duration, scope string, inputRef *InputReference, ...) error
- func SetTaskInputStorageEnabled(enabled bool)
- func TaskInputStorageEnabled() bool
- func WaitForJobToComplete(ctx context.Context, timeout time.Duration, jobKey JobKey, engine Engine) error
- type AppError
- type AppErrorOutcome
- type AppErrorPayload
- type ApplicationInputBytes
- type ApplicationOutputBytes
- type ApplicationOutputOutcome
- type Artifact
- func NewArtifact(name string, opener func() (io.ReadCloser, int64, error), cleanup func() error) Artifact
- func NewArtifactFromBytes(name string, data []byte) Artifact
- func NewArtifactFromFile(name string, filePath string) (Artifact, error)
- func NewArtifactFromFileNoCleanup(name string, filePath string) (Artifact, error)
- func NewArtifactFromReader(name string, r io.Reader, size int64) Artifact
- type ArtifactInfo
- type ArtifactKey
- type ArtifactReader
- type ArtifactRef
- type ArtifactUpload
- type CancelJob
- type CancelJobRequest
- type CatchDisposition
- type CatchResult
- type CatchRule
- type Chapter
- type ChapterBody
- type ChapterMetadata
- type ChapterMetadataKind
- type ChapterMetadataValue
- type ChapterOutcome
- type ChapterRef
- type ClientPayloadUpdate
- type CompleteExecutionRequest
- type CompleteTaskIfWaitingRequest
- type ConfigurationSnapshot
- type Data
- type Duration
- type Engine
- type EngineBuilder
- func (b *EngineBuilder) BuildEngine() (Engine, error)
- func (e *EngineBuilder) PlusWorkers(jobWorker JobWorker, taskWorkers ...TaskWorker) *EngineBuilder
- func (e *EngineBuilder) PlusWorkersWithOptions(jobWorker JobWorker, opts WorkRegistrationOptions, taskWorkers ...TaskWorker) *EngineBuilder
- func (e *EngineBuilder) WithAwaitRecycleThreshold(d time.Duration) *EngineBuilder
- func (e *EngineBuilder) WithLogger(logger *slog.Logger) *EngineBuilder
- func (e *EngineBuilder) WithMaxActive(maxActive int) *EngineBuilder
- func (e *EngineBuilder) WithRuntime(runtime WorkflowRuntime) *EngineBuilder
- func (e *EngineBuilder) WithWorkerTenantId(tenantId string) *EngineBuilder
- type EnvelopedTaskData
- type ExecutionChapter
- type ExecutionContext
- type ExecutionLease
- type ExecutionState
- type ExecutionWorker
- type FieldName
- type FindTasksWaitingRequest
- type GetJobForRunRequest
- type GetJobLeaseRequest
- type GetJobRunRequest
- type GetJobRunResponse
- type Handoff
- type InputReference
- type JobAttempt
- type JobAttemptOutcomeChapter
- type JobContext
- type JobData
- type JobEndEvent
- type JobFailedError
- type JobHandle
- type JobInfo
- type JobKey
- type JobPrereqCondition
- type JobPrerequisite
- type JobRunListener
- type JobRunOutcome
- type JobRunStatus
- type JobRunSummary
- type JobRunnable
- type JobStart
- type JobStartChapter
- type JobStartEvent
- type JobStatus
- type JobStore
- type JobSummary
- type JobTaskFilter
- type JobWorker
- type ListChaptersRequest
- type ListJobsRequest
- type ListJobsResponse
- type ListScheduleRunsRequest
- type ListScheduleRunsResponse
- type ListSchedulesRequest
- type ListSchedulesResponse
- type MetadataFilter
- type MetadataPredicate
- type NonRetryableError
- type PollWorkRequest
- type PutChapterRequest
- type ReplayCacheMissError
- type ReplayCacheMissReason
- type ReplayObserver
- type ReplayRunRequest
- type RescheduleExecutionRequest
- type RestartExtraChapter
- type RetryPolicy
- type Route
- type RunPolicy
- type RuntimeBuildOptions
- type ScheduleFailurePolicy
- type ScheduleInfo
- type ScheduleKey
- type ScheduleMutationRequest
- type ScheduleOverlapPolicy
- type ScheduleRunSummary
- type ScheduleSpec
- type ScheduleState
- type ScheduleTarget
- type ScheduleTrigger
- type ScheduleTriggerKind
- type ScopeOptions
- type SecretResolveResult
- type SecretValue
- type SimpleTaskData
- type StoredArtifact
- type SubmitJob
- type SubmitJobRequest
- type SubmitRestartJob
- type SubmitRestartJobRequest
- type SystemError
- type SystemErrorOutcome
- type SystemErrorPayload
- type TaskAlternate
- type TaskAlternateAfter
- type TaskAttempt
- type TaskAttemptOutcomeChapter
- type TaskCall
- type TaskCompletion
- type TaskContext
- func (tc TaskContext) AwaitDuration(waitFor Duration) error
- func (tc TaskContext) AwaitJobs(jobIds ...string) error
- func (tc TaskContext) ClientPayload() json.RawMessage
- func (tc TaskContext) ClientPayloadRevision() int64
- func (tc TaskContext) Context() context.Context
- func (tc TaskContext) GetConfiguration(ctx context.Context) (ConfigurationSnapshot, error)
- func (tc TaskContext) ResolveSecrets(ctx context.Context, names []string) (SecretResolveResult, error)
- func (tc TaskContext) SubmitJob(ctx context.Context, submit SubmitJob) (JobKey, error)
- func (tc TaskContext) SubmitRestartJob(ctx context.Context, restart SubmitRestartJob) (JobKey, error)
- func (tc TaskContext) Yield(ctx context.Context, req YieldRequest) error
- type TaskData
- type TaskDeterminismMeta
- type TaskEndEvent
- type TaskError
- type TaskHandle
- type TaskIO
- type TaskInputMismatchError
- func (e TaskInputMismatchError) CachedInputPayload() json.RawMessage
- func (e TaskInputMismatchError) CachedTaskData() TaskData
- func (e TaskInputMismatchError) CachedTaskDataErr() error
- func (e TaskInputMismatchError) ChapterMeta() TaskDeterminismMeta
- func (e TaskInputMismatchError) Error() string
- func (e TaskInputMismatchError) Unwrap() error
- type TaskOptions
- type TaskOutcome
- type TaskRun
- type TaskRuntime
- type TaskStartEvent
- type TaskWait
- type TaskWorker
- type TimeoutError
- type TimeoutOutcome
- type TimeoutPayload
- type TriggerScheduleRequest
- type UpsertScheduleRequest
- type WorkRegistrationOptions
- type WorkSet
- type Worker
- type WorkflowRuntime
- type YieldRequest
Constants ¶
const ( JobPrereqComplete = jobdb.JobPrereqComplete JobPrereqSuccess = jobdb.JobPrereqSuccess JobStatusReady = jobdb.JobStatusReady JobStatusExpired = jobdb.JobStatusExpired JobStatusPendingJobs = jobdb.JobStatusPendingJobs JobStatusAwaitingFuture = jobdb.JobStatusAwaitingFuture JobStatusActive = jobdb.JobStatusActive JobStatusCrashConcern = jobdb.JobStatusCrashConcern JobStatusCancelled = jobdb.JobStatusCancelled JobStatusCompleted = jobdb.JobStatusCompleted )
const ( DefaultListJobsPageSize = jobdb.DefaultListJobsPageSize MaxListJobsPageSize = jobdb.MaxListJobsPageSize )
const ( TaskAttemptStateSucceeded = jobdb.TaskAttemptStateSucceeded TaskAttemptStateFailed = jobdb.TaskAttemptStateFailed TaskAttemptStateReady = jobdb.TaskAttemptStateReady TaskAttemptStateLeased = jobdb.TaskAttemptStateLeased TaskAttemptStateWaiting = jobdb.TaskAttemptStateWaiting TaskAttemptStateRunning = jobdb.TaskAttemptStateRunning TaskOutcomeStatusSucceeded = jobdb.TaskOutcomeStatusSucceeded TaskOutcomeStatusFailed = jobdb.TaskOutcomeStatusFailed TaskErrorKindApp = jobdb.TaskErrorKindApp TaskErrorKindSystem = jobdb.TaskErrorKindSystem TaskErrorKindTimeout = jobdb.TaskErrorKindTimeout TimeoutScopeInvocation = jobdb.TimeoutScopeInvocation TimeoutScopeTotal = jobdb.TimeoutScopeTotal )
const ( ChapterMetadataNull = jobdb.ChapterMetadataNull ChapterMetadataBool = jobdb.ChapterMetadataBool ChapterMetadataInt = jobdb.ChapterMetadataInt ChapterMetadataDouble = jobdb.ChapterMetadataDouble ChapterMetadataString = jobdb.ChapterMetadataString ChapterMetadataList = jobdb.ChapterMetadataList ChapterMetadataMap = jobdb.ChapterMetadataMap )
Variables ¶
var ( ErrChapterNotFound = jobdb.ErrChapterNotFound ErrConflict = jobdb.ErrConflict ErrExecutionLeaseLost = jobdb.ErrExecutionLeaseLost ErrExistingJobMismatch = jobdb.ErrExistingJobMismatch ErrJobCancelled = jobdb.ErrJobCancelled ErrJobFailed = jobdb.ErrJobFailed ErrJobNotComplete = jobdb.ErrJobNotComplete ErrJobNotFound = jobdb.ErrJobNotFound ErrMissingInputHash = jobdb.ErrMissingInputHash ErrWorkflowNotDeterministic = jobdb.ErrWorkflowNotDeterministic )
var ErrReplayShouldNeverMutate = errors.New("replay run should never mutate state")
ErrReplayShouldNeverMutate signals replay attempted to mutate state.
Functions ¶
func AssignArtifactKey ¶
func AssignArtifactKey(art Artifact, key ArtifactKey)
func IsAppError ¶
func IsConflict ¶
func IsExecutionLeaseLost ¶
func IsExecutionSuspended ¶ added in v0.0.40
IsExecutionSuspended recognizes the suspension control error through wrappers. Propagate it to stop task execution. It does not order post-Yield code before Run returns; use JobRunOutcome.Handoff to publish handoff notifications.
func IsExistingJobMismatch ¶
func IsSystemError ¶
func NewSystemError ¶
func NewSystemError(payload SystemErrorPayload) error
func NewTimeoutError ¶
func SetTaskInputStorageEnabled ¶
func SetTaskInputStorageEnabled(enabled bool)
SetTaskInputStorageEnabled controls whether task inputs are stored in chapters. Enabled by default.
func TaskInputStorageEnabled ¶
func TaskInputStorageEnabled() bool
TaskInputStorageEnabled reports whether task input storage is enabled.
Types ¶
type AppErrorOutcome ¶
type AppErrorOutcome = jobdb.AppErrorOutcome
type AppErrorPayload ¶
type AppErrorPayload = jobdb.AppErrorPayload
type ApplicationInputBytes ¶
type ApplicationInputBytes = jobdb.ApplicationInputBytes
type ApplicationOutputBytes ¶
type ApplicationOutputBytes = jobdb.ApplicationOutputBytes
type ApplicationOutputOutcome ¶
type ApplicationOutputOutcome = jobdb.ApplicationOutputOutcome
type ArtifactInfo ¶
type ArtifactInfo = jobdb.ArtifactInfo
type ArtifactKey ¶
type ArtifactKey = jobdb.ArtifactKey
type ArtifactReader ¶
type ArtifactReader = jobdb.ArtifactReader
type ArtifactRef ¶
type ArtifactRef = jobdb.ArtifactRef
type ArtifactUpload ¶
type ArtifactUpload = jobdb.ArtifactUpload
type CancelJobRequest ¶
type CancelJobRequest = jobdb.CancelJobRequest
type CatchDisposition ¶ added in v0.0.36
type CatchDisposition string
const ( CatchHandled CatchDisposition = "handled" CatchContinue CatchDisposition = "continue" CatchPropagate CatchDisposition = "propagate" )
type CatchResult ¶ added in v0.0.36
type CatchResult struct {
Disposition CatchDisposition
Output TaskData
Err error
}
type CatchRule ¶ added in v0.0.36
type CatchRule struct {
ID string
Match func(error) bool
Handle func(ExecutionContext, error) (CatchResult, error)
}
type ChapterBody ¶
type ChapterBody = jobdb.ChapterBody
type ChapterMetadata ¶
type ChapterMetadata = jobdb.ChapterMetadata
type ChapterMetadataKind ¶
type ChapterMetadataKind = jobdb.ChapterMetadataKind
type ChapterMetadataValue ¶
type ChapterMetadataValue = jobdb.ChapterMetadataValue
type ChapterOutcome ¶
type ChapterOutcome = jobdb.ChapterOutcome
type ChapterRef ¶
type ChapterRef = jobdb.ChapterRef
type ClientPayloadUpdate ¶ added in v0.0.18
type ClientPayloadUpdate = jobdb.ClientPayloadUpdate
type CompleteExecutionRequest ¶
type CompleteExecutionRequest = jobdb.CompleteExecutionRequest
type CompleteTaskIfWaitingRequest ¶
type CompleteTaskIfWaitingRequest = jobdb.CompleteTaskIfWaitingRequest
type ConfigurationSnapshot ¶ added in v0.0.33
type ConfigurationSnapshot = jobdb.ConfigurationSnapshot
type Duration ¶
func AsDuration ¶
type EngineBuilder ¶
type EngineBuilder struct {
// contains filtered or unexported fields
}
func NewEngineBuilder ¶
func NewEngineBuilder() *EngineBuilder
func (*EngineBuilder) BuildEngine ¶
func (b *EngineBuilder) BuildEngine() (Engine, error)
func (*EngineBuilder) PlusWorkers ¶
func (e *EngineBuilder) PlusWorkers(jobWorker JobWorker, taskWorkers ...TaskWorker) *EngineBuilder
func (*EngineBuilder) PlusWorkersWithOptions ¶
func (e *EngineBuilder) PlusWorkersWithOptions(jobWorker JobWorker, opts WorkRegistrationOptions, taskWorkers ...TaskWorker) *EngineBuilder
func (*EngineBuilder) WithAwaitRecycleThreshold ¶
func (e *EngineBuilder) WithAwaitRecycleThreshold(d time.Duration) *EngineBuilder
WithAwaitRecycleThreshold configures how far in the future a wait must be before recycling the runner.
func (*EngineBuilder) WithLogger ¶
func (e *EngineBuilder) WithLogger(logger *slog.Logger) *EngineBuilder
func (*EngineBuilder) WithMaxActive ¶
func (e *EngineBuilder) WithMaxActive(maxActive int) *EngineBuilder
func (*EngineBuilder) WithRuntime ¶
func (e *EngineBuilder) WithRuntime(runtime WorkflowRuntime) *EngineBuilder
func (*EngineBuilder) WithWorkerTenantId ¶
func (e *EngineBuilder) WithWorkerTenantId(tenantId string) *EngineBuilder
WithWorkerTenantId configures the tenant polled by the worker loop. Engines with registered workers must set this before BuildEngine.
type EnvelopedTaskData ¶
type EnvelopedTaskData = jobdb.EnvelopedTaskData
type ExecutionChapter ¶ added in v0.0.36
type ExecutionChapter = jobdb.ExecutionChapter
type ExecutionContext ¶ added in v0.0.36
type ExecutionContext interface {
Context() context.Context
GetJobKey() JobKey
Logger() *slog.Logger
ExecutionVersions() jobdb.ExecutionVersions
DoTask(TaskCall, func(context.Context) (TaskData, error)) (TaskData, error)
DoScope(string, ScopeOptions, func(ExecutionContext) (JobData, error)) (JobData, error)
AwaitDuration(Duration) error
AwaitJobs(...string) error
GetConfiguration(context.Context) (ConfigurationSnapshot, error)
ResolveSecrets(context.Context, []string) (SecretResolveResult, error)
ClientPayload() json.RawMessage
ClientPayloadRevision() int64
SubmitJob(context.Context, SubmitJob) (JobKey, error)
SubmitRestartJob(context.Context, SubmitRestartJob) (JobKey, error)
// Yield reschedules and stops execution. Read JobRunOutcome.Handoff after
// Run returns for confirmation; post-Yield user code may still be running.
Yield(context.Context, YieldRequest) error
}
type ExecutionLease ¶
type ExecutionLease = jobdb.ExecutionLease
type ExecutionState ¶ added in v0.0.18
type ExecutionState = jobdb.ExecutionState
type ExecutionWorker ¶ added in v0.0.36
type ExecutionWorker struct {
JobType string
Execute func(ExecutionContext, JobData) (JobData, error)
}
ExecutionWorker selects the versioned invocation/scope engine. It is the temporary registration surface while consumers migrate off JobWorker.Run.
func (ExecutionWorker) Name ¶ added in v0.0.36
func (w ExecutionWorker) Name() string
func (ExecutionWorker) Run ¶ added in v0.0.36
func (w ExecutionWorker) Run(JobContext, JobData) (JobData, error)
type FindTasksWaitingRequest ¶
type FindTasksWaitingRequest struct {
JobType string
TaskType string
TenantIds []string
MetadataFilter MetadataFilter
Limit int
}
type GetJobForRunRequest ¶
type GetJobForRunRequest struct {
ConsumerVersions map[string]string
// BeforeRun runs under the validated, renewing lease before application work.
// It may reschedule the supplied lease to reject execution admission.
BeforeRun func(context.Context, ExecutionLease) error
JobKey JobKey
JobWorker JobWorker
TaskWorkers []TaskWorker
WorkerID string
LeaseDuration time.Duration
Logger *slog.Logger
// If the job awaits longer than this, the lease is rescheduled instead of
// sleeping inline. Zero uses the existing default behavior.
AwaitThreshold time.Duration
}
type GetJobLeaseRequest ¶
type GetJobLeaseRequest = jobdb.GetJobLeaseRequest
type GetJobRunRequest ¶
type GetJobRunRequest = jobdb.GetJobRunRequest
type GetJobRunResponse ¶
type GetJobRunResponse = jobdb.GetJobRunResponse
func GetJobRun ¶
func GetJobRun(ctx context.Context, runtime WorkflowRuntime, req GetJobRunRequest) (GetJobRunResponse, error)
type Handoff ¶ added in v0.0.41
type Handoff struct {
NextRoute Route
Metadata json.RawMessage
}
Handoff is this Run's acknowledged explicit Yield, not the job's current scheduler state. It is captured before suspension and never inferred from another worker's actions. It does not represent notification delivery.
type InputReference ¶
type InputReference = jobdb.InputReference
type JobAttempt ¶
type JobAttempt = jobdb.JobAttempt
type JobAttemptOutcomeChapter ¶
type JobAttemptOutcomeChapter = jobdb.JobAttemptOutcomeChapter
type JobContext ¶
type JobContext interface {
// GetConfiguration returns a copy of the first successful tenant snapshot in
// this live job attempt. Tasks share the same cache; whole-job retries reset it.
GetConfiguration(context.Context) (ConfigurationSnapshot, error)
// ResolveSecrets retrieves allowed names under this invocation's live lease.
// Values and omissions are cached by name for this live job attempt, never
// recorded. New names refresh all cached available names together; known omissions
// are not retried. Offline replay rejects reads;
// use task-level resolution for workflows that must support offline replay.
ResolveSecrets(context.Context, []string) (SecretResolveResult, error)
ClientPayload() json.RawMessage
ClientPayloadRevision() int64
// Yield reschedules and stops this invocation. It never writes a chapter.
Yield(context.Context, YieldRequest) error
GetJobKey() JobKey
Logger() *slog.Logger
DoTask(policy RunPolicy, taskType string, data TaskData) (TaskData, error)
AwaitDuration(waitFor Duration) error
AwaitJobs(jobIds ...string) error
SubmitJob(ctx context.Context, submit SubmitJob) (JobKey, error)
SubmitRestartJob(ctx context.Context, restart SubmitRestartJob) (JobKey, error)
}
type JobEndEvent ¶
type JobFailedError ¶
type JobFailedError = jobdb.JobFailedError
type JobPrereqCondition ¶
type JobPrereqCondition = jobdb.JobPrereqCondition
type JobPrerequisite ¶
type JobPrerequisite = jobdb.JobPrerequisite
type JobRunListener ¶
type JobRunListener interface {
OnJobStart(event JobStartEvent)
OnTaskStart(event TaskStartEvent)
OnTaskEnd(event TaskEndEvent)
OnJobEnd(event JobEndEvent)
}
type JobRunOutcome ¶
type JobRunOutcome struct {
// Handoff is set only for an explicit Yield acknowledged during this Run.
// Read it after Run returns; no task callback needs to finish first.
Handoff *Handoff
Status JobRunStatus
LeaseAcquired bool
// Set when Status == COMPLETED.
Output JobData
// Set when Status == FAILED.
JobError error
// Best-effort job state details, mainly useful when Status == SUSPENDED
// or NOT_LEASEABLE. For a confirmed handoff, NextRoute is the acknowledged
// route; these fields are not refreshed from the scheduler.
JobStatus *JobStatus
NextRoute *Route
WaitForJobIDs []string
MissingRoute *Route
}
type JobRunStatus ¶
type JobRunStatus string
const ( JobRunNotLeaseable JobRunStatus = "NOT_LEASEABLE" JobRunCompleted JobRunStatus = "COMPLETED" JobRunFailed JobRunStatus = "FAILED" JobRunSuspended JobRunStatus = "SUSPENDED" )
type JobRunSummary ¶
type JobRunSummary = jobdb.JobRunSummary
type JobRunnable ¶
type JobRunnable struct {
// contains filtered or unexported fields
}
func GetJobForRun ¶
func GetJobForRun(ctx context.Context, runtime WorkflowRuntime, req GetJobForRunRequest) (*JobRunnable, error)
func GetJobForRunWithLease ¶ added in v0.0.22
func GetJobForRunWithLease(ctx context.Context, runtime WorkflowRuntime, lease ExecutionLease, req GetJobForRunRequest) (*JobRunnable, error)
GetJobForRunWithLease prepares one invocation using existing authority. It never acquires work. Validation and renewal occur when Run starts, so a delay between preparation and execution cannot bypass the authority check.
func (*JobRunnable) JobKey ¶
func (r *JobRunnable) JobKey() JobKey
func (*JobRunnable) LeaseAcquired ¶
func (r *JobRunnable) LeaseAcquired() bool
func (*JobRunnable) Outcome ¶
func (r *JobRunnable) Outcome() (JobRunOutcome, bool)
func (*JobRunnable) Run ¶
func (r *JobRunnable) Run(listener JobRunListener) (JobRunOutcome, error)
type JobStartChapter ¶
type JobStartChapter = jobdb.JobStartChapter
type JobStartEvent ¶
type JobSummary ¶
type JobSummary = jobdb.JobSummary
type JobTaskFilter ¶
type JobTaskFilter = jobdb.JobTaskFilter
type JobWorker ¶
type JobWorker interface {
Name() string
Run(JobContext, JobData) (JobData, error)
}
type ListChaptersRequest ¶
type ListChaptersRequest = jobdb.ListChaptersRequest
type ListJobsRequest ¶
type ListJobsRequest = jobdb.ListJobsRequest
type ListJobsResponse ¶
type ListJobsResponse = jobdb.ListJobsResponse
type ListScheduleRunsRequest ¶
type ListScheduleRunsRequest = jobdb.ListScheduleRunsRequest
type ListScheduleRunsResponse ¶
type ListScheduleRunsResponse = jobdb.ListScheduleRunsResponse
type ListSchedulesRequest ¶
type ListSchedulesRequest = jobdb.ListSchedulesRequest
type ListSchedulesResponse ¶
type ListSchedulesResponse = jobdb.ListSchedulesResponse
type MetadataFilter ¶
type MetadataFilter = jobdb.MetadataFilter
func Metadata ¶
func Metadata() MetadataFilter
type MetadataPredicate ¶
type MetadataPredicate = jobdb.MetadataPredicate
func MetadataPredicates ¶
func MetadataPredicates(filter MetadataFilter) ([]MetadataPredicate, error)
type NonRetryableError ¶
type NonRetryableError = jobdb.NonRetryableError
type PollWorkRequest ¶
type PollWorkRequest = jobdb.PollWorkRequest
type PutChapterRequest ¶
type PutChapterRequest = jobdb.PutChapterRequest
type ReplayCacheMissError ¶
type ReplayCacheMissError struct {
JobKey JobKey
TaskType string
Ordinal int64
Attempt int
Reason ReplayCacheMissReason
}
ReplayCacheMissError indicates replay could not proceed due to missing cached data.
func (ReplayCacheMissError) Error ¶
func (e ReplayCacheMissError) Error() string
type ReplayCacheMissReason ¶
type ReplayCacheMissReason string
const ( ReplayCacheMissTaskResultMissing ReplayCacheMissReason = "task_result_missing" ReplayCacheMissJobResultMissing ReplayCacheMissReason = "job_result_missing" ReplayCacheMissAwaitNotReady ReplayCacheMissReason = "await_not_ready" ReplayCacheMissAwaitJobsPending ReplayCacheMissReason = "await_jobs_pending" )
type ReplayObserver ¶
type ReplayObserver interface {
OnJobStart(event JobStartEvent)
OnTaskStart(event TaskStartEvent)
OnTaskEnd(event TaskEndEvent)
OnJobEnd(event JobEndEvent)
}
ReplayObserver receives lifecycle events during replay.
type ReplayRunRequest ¶
type ReplayRunRequest struct {
JobKey JobKey
Observer ReplayObserver // optional
// Optional job worker override for replay-time instrumentation.
// If nil, the registered job worker is used.
JobWorker JobWorker
}
ReplayRunRequest describes a cache-only job replay.
type RescheduleExecutionRequest ¶
type RescheduleExecutionRequest = jobdb.RescheduleExecutionRequest
type RestartExtraChapter ¶
type RestartExtraChapter = jobdb.RestartExtraChapter
type RetryPolicy ¶
type RetryPolicy = jobdb.RetryPolicy
type RunPolicy ¶
func DefaultRunPolicy ¶
func DefaultRunPolicy() RunPolicy
type RuntimeBuildOptions ¶
type ScheduleFailurePolicy ¶
type ScheduleFailurePolicy = jobdb.ScheduleFailurePolicy
type ScheduleInfo ¶
type ScheduleInfo = jobdb.ScheduleInfo
type ScheduleKey ¶
type ScheduleKey = jobdb.ScheduleKey
type ScheduleMutationRequest ¶
type ScheduleMutationRequest = jobdb.ScheduleMutationRequest
type ScheduleOverlapPolicy ¶
type ScheduleOverlapPolicy = jobdb.ScheduleOverlapPolicy
type ScheduleRunSummary ¶
type ScheduleRunSummary = jobdb.ScheduleRunSummary
type ScheduleSpec ¶
type ScheduleSpec = jobdb.ScheduleSpec
type ScheduleState ¶
type ScheduleState = jobdb.ScheduleState
type ScheduleTarget ¶
type ScheduleTarget = jobdb.ScheduleTarget
type ScheduleTrigger ¶
type ScheduleTrigger = jobdb.ScheduleTrigger
type ScheduleTriggerKind ¶
type ScheduleTriggerKind = jobdb.ScheduleTriggerKind
type ScopeOptions ¶ added in v0.0.36
type ScopeOptions struct {
TotalTimeout time.Duration
AttemptTimeout time.Duration
Retry RetryPolicy
Catch []CatchRule
// OnRestart runs with fresh consumer state before the selected scope body.
OnRestart func(json.RawMessage) error
}
type SecretResolveResult ¶ added in v0.0.30
type SecretResolveResult = jobdb.SecretResolveResult
type SecretValue ¶ added in v0.0.30
type SecretValue = jobdb.SecretValue
type SimpleTaskData ¶
type SimpleTaskData = jobdb.SimpleTaskData
type StoredArtifact ¶
type StoredArtifact = jobdb.StoredArtifact
type SubmitJobRequest ¶
type SubmitJobRequest = jobdb.SubmitJobRequest
type SubmitRestartJob ¶
type SubmitRestartJob = jobdb.SubmitRestartJob
type SubmitRestartJobRequest ¶
type SubmitRestartJobRequest = jobdb.SubmitRestartJobRequest
type SystemError ¶
type SystemError = jobdb.SystemError
type SystemErrorOutcome ¶
type SystemErrorOutcome = jobdb.SystemErrorOutcome
type SystemErrorPayload ¶
type SystemErrorPayload = jobdb.SystemErrorPayload
type TaskAlternate ¶ added in v0.0.23
TaskAlternate declares another implementation of the same logical task. At is an absolute eligibility time, not a deadline for external completion.
type TaskAlternateAfter ¶ added in v0.0.38
type TaskAlternateAfter struct {
TaskType string `json:"task_type"`
After time.Duration `json:"after"`
}
TaskAlternateAfter makes another implementation eligible after a durable external wait. A locally registered primary still executes immediately. After starts at the first wait and is preserved across recovery. Acquisition of the alternate commits its selection for subsequent task retries. The due time is not a strict cutoff for external answers; normal lease fencing applies.
type TaskAttempt ¶
type TaskAttempt = jobdb.TaskAttempt
type TaskAttemptOutcomeChapter ¶
type TaskAttemptOutcomeChapter = jobdb.TaskAttemptOutcomeChapter
type TaskCall ¶ added in v0.0.36
type TaskCall struct {
Site string `json:"site"`
TaskType string `json:"task_type"`
ContractVersion uint32 `json:"contract_version"`
Command json.RawMessage `json:"command"`
Policy RunPolicy `json:"policy"`
Catch []CatchRule `json:"-"`
Alternate *TaskAlternateAfter `json:"alternate,omitempty"`
}
type TaskCompletion ¶
type TaskContext ¶
type TaskContext struct {
JobKey JobKey
// Step is the outcome ordinal for this call to Run. In the versioned
// engine it remains valid across in-process waits. Suspension or lease loss
// ends the call; a resumed Run gets a new context and may have a new Step.
Step int64
// InvocationID identifies the logical task within JobKey in the versioned
// engine. It survives task retries and recovery, but changes when an enclosing
// scope or whole job retries. It is empty for the legacy JobWorker engine.
InvocationID string
// AttemptNumber is one-based in the versioned engine. Recovery of unfinished
// work retains the attempt; a task retry increments it. Legacy contexts use 0.
AttemptNumber int
Logger *slog.Logger
// contains filtered or unexported fields
}
func NewTaskContext ¶
func NewTaskContext(jobKey JobKey, step int64, logger *slog.Logger, await func(time.Time) error, awaitJobs func(...string) error) TaskContext
NewTaskContext builds a task context with an optional await handler.
func (TaskContext) AwaitDuration ¶
func (tc TaskContext) AwaitDuration(waitFor Duration) error
AwaitDuration pauses task execution for the specified duration. The engine may override this to reschedule work or recycle runners.
func (TaskContext) AwaitJobs ¶
func (tc TaskContext) AwaitJobs(jobIds ...string) error
AwaitJobs waits for the provided job IDs to complete.
func (TaskContext) ClientPayload ¶ added in v0.0.18
func (tc TaskContext) ClientPayload() json.RawMessage
func (TaskContext) ClientPayloadRevision ¶ added in v0.0.18
func (tc TaskContext) ClientPayloadRevision() int64
func (TaskContext) Context ¶ added in v0.0.36
func (tc TaskContext) Context() context.Context
Context is canceled when this execution attempt ends or loses its lease.
func (TaskContext) GetConfiguration ¶ added in v0.0.33
func (tc TaskContext) GetConfiguration(ctx context.Context) (ConfigurationSnapshot, error)
GetConfiguration reads the complete tenant configuration using the current invocation's live lease. The first successful read is cached for the live job attempt and shared with other tasks. Each call returns a caller-owned copy. Nothing is prefetched or automatically recorded in workflow history.
func (TaskContext) ResolveSecrets ¶ added in v0.0.30
func (tc TaskContext) ResolveSecrets(ctx context.Context, names []string) (SecretResolveResult, error)
ResolveSecrets retrieves allowed names using the current task's live lease. Values and omissions are cached by name for the live job attempt. Requesting a new name refreshes all previously available names together. Known omissions are not retried. Each result is a caller-owned copy. Results are never recorded in workflow history; do not include values in task outputs, artifacts, or errors.
func (TaskContext) SubmitJob ¶ added in v0.0.13
SubmitJob starts a child job using the current job lease.
func (TaskContext) SubmitRestartJob ¶ added in v0.0.13
func (tc TaskContext) SubmitRestartJob(ctx context.Context, restart SubmitRestartJob) (JobKey, error)
SubmitRestartJob starts a child restart job using the current job lease.
func (TaskContext) Yield ¶ added in v0.0.18
func (tc TaskContext) Yield(ctx context.Context, req YieldRequest) error
Yield reschedules and stops execution. Use JobRunOutcome.Handoff to report the confirmed transition; code following Yield may run after Run returns.
type TaskData ¶
func ExtractTaskDataResult ¶
func NewTaskDataOrPanic ¶
func WithTaskOptions ¶ added in v0.0.23
func WithTaskOptions(data TaskData, options TaskOptions) TaskData
WithTaskOptions attaches invocation options without changing the input bytes, artifacts, logical task identity, or input hash. It also works through existing JobContext wrappers. Wrappers replacing TaskData must preserve TaskOptionsFor.
type TaskDeterminismMeta ¶
type TaskDeterminismMeta struct {
Ordinal int64 `json:"ordinal"`
TaskType string `json:"task_type"`
WorkerID string `json:"worker_id,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
Attempt int `json:"attempt,omitempty"`
MaxAttempts int `json:"max_attempts,omitempty"`
NextAttemptAt *time.Time `json:"next_attempt_at,omitempty"`
BackoffMillis int64 `json:"backoff_ms,omitempty"`
Retryable *bool `json:"retryable,omitempty"`
InputHash string `json:"input_hash,omitempty"`
InputRef *InputReference `json:"input_ref,omitempty"`
RunPolicy *RunPolicy `json:"run_policy,omitempty"`
InputPayload json.RawMessage `json:"input_payload,omitempty"`
Version int `json:"version,omitempty"`
}
TaskDeterminismMeta exposes deterministic metadata persisted with a task chapter. It is a public, minimal view of the internal chapter metadata used for replay.
type TaskEndEvent ¶
type TaskHandle ¶
type TaskInputMismatchError ¶
type TaskInputMismatchError struct {
TaskType string
Ordinal int64
CachedInputHash string
ComputedInputHash string
CachedInput json.RawMessage
CachedOutput TaskData
CachedOutputErr error
Meta TaskDeterminismMeta
}
TaskInputMismatchError is returned when a cached task chapter's input hash does not match the hash of the current DoTask input. It unwraps to ErrWorkflowNotDeterministic so existing callers can continue using errors.Is.
func UnexpectedChapter ¶
func UnexpectedChapter(err error) (TaskInputMismatchError, bool)
UnexpectedChapter extracts TaskInputMismatchError from err, if present.
func (TaskInputMismatchError) CachedInputPayload ¶
func (e TaskInputMismatchError) CachedInputPayload() json.RawMessage
CachedInputPayload returns the persisted task input payload, when task input storage is enabled.
func (TaskInputMismatchError) CachedTaskData ¶
func (e TaskInputMismatchError) CachedTaskData() TaskData
CachedTaskData returns the cached task output (if it could be rehydrated).
func (TaskInputMismatchError) CachedTaskDataErr ¶
func (e TaskInputMismatchError) CachedTaskDataErr() error
CachedTaskDataErr reports any error encountered while rehydrating the cached output.
func (TaskInputMismatchError) ChapterMeta ¶
func (e TaskInputMismatchError) ChapterMeta() TaskDeterminismMeta
ChapterMeta exposes the deterministic metadata captured with the cached chapter.
func (TaskInputMismatchError) Error ¶
func (e TaskInputMismatchError) Error() string
func (TaskInputMismatchError) Unwrap ¶
func (e TaskInputMismatchError) Unwrap() error
Unwrap preserves compatibility with errors.Is(err, ErrWorkflowNotDeterministic).
type TaskOptions ¶ added in v0.0.23
type TaskOptions struct {
Alternate *TaskAlternate `json:"alternate,omitempty"`
}
TaskOptions controls dispatch independently of timeout and retry policy. Reconstruct these options from durable workflow state on every replay.
func TaskOptionsFor ¶ added in v0.0.23
func TaskOptionsFor(data TaskData) TaskOptions
type TaskOutcome ¶
type TaskOutcome = jobdb.TaskOutcome
type TaskRuntime ¶
type TaskRuntime = jobdb.TaskRuntime
type TaskStartEvent ¶
type TaskWorker ¶
type TaskWorker interface {
Name() string
Run(context TaskContext, input TaskData) (TaskData, error)
}
type TimeoutError ¶
type TimeoutError = jobdb.TimeoutError
type TimeoutOutcome ¶
type TimeoutOutcome = jobdb.TimeoutOutcome
type TimeoutPayload ¶
type TimeoutPayload = jobdb.TimeoutPayload
type TriggerScheduleRequest ¶
type TriggerScheduleRequest = jobdb.TriggerScheduleRequest
type UpsertScheduleRequest ¶
type UpsertScheduleRequest = jobdb.UpsertScheduleRequest
type WorkRegistrationOptions ¶
type WorkRegistrationOptions struct {
ConsumerVersions map[string]string
MetadataFilter MetadataFilter
}
type WorkSet ¶
type WorkSet struct {
JobWorker JobWorker
TaskWorkers map[string]TaskWorker
Options WorkRegistrationOptions
// contains filtered or unexported fields
}
func AsWorkSetWithOptions ¶
func AsWorkSetWithOptions(jobWorker JobWorker, opts WorkRegistrationOptions, taskWorkers ...TaskWorker) (*WorkSet, error)
type WorkflowRuntime ¶
type WorkflowRuntime = jobdb.WorkflowRuntime
type YieldRequest ¶ added in v0.0.41
type YieldRequest struct {
Reschedule RescheduleExecutionRequest
Metadata json.RawMessage
}
YieldRequest describes an explicit handoff. Metadata is optional consumer JSON returned in JobRunOutcome.Handoff; it is not sent to storage or recorded in task history. Persist anything needed for recovery through Reschedule itself.
Source Files
¶
- aliases.go
- attempt_cache.go
- configuration.go
- core.go
- determinism.go
- execution_api.go
- execution_external.go
- execution_history.go
- execution_restart.go
- execution_scope.go
- execution_task.go
- invocation_context.go
- jobs.go
- lease_session.go
- loop.go
- replay.go
- run_job_if_leaseable.go
- runtime_engine.go
- runtime_task_handle.go
- secrets.go
- support_helpers.go
- task_input_storage.go
- task_options.go
- tasks.go
- worker_engine.go
- worker_envelope.go
- worker_retry.go
- worker_runner.go
- worker_runtime_support.go
- yield.go