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

executionruntime

package
v0.0.98 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

README

Execution-aware JobDB runtime

Wrap a persistent JobDB runtime with executionruntime.New(runtime, allocation, onHandoff). Pass the same normalized allocation and callback to compiler.RecipeJobWorkerOptions, with StageExecution: wrapped.Stage and WrapTaskWorker: wrapped.WrapTaskWorker, and build the engine using the wrapped runtime. Register schemas using the original runtime. The CLI performs this wiring for all execution entry points.

The recipe reconstructs requirements from its input and retained activity results on every invocation. It never restores execution state from client payload. The compiler stages effective requirements before each task call. Guarded task workers check them only after JobDB decides the task is unfinished. Satisfied requirements allow execution; a mismatch publishes the requirements and yields. Cached tasks never request historical environments, including when recovery starts through a stale task route.

Wrap every task worker with WrapTaskWorker and supply that same function in the recipe worker options. Resource and image constraints require this guard; staging alone cannot enforce a live-task boundary.

Node scopes are ephemeral. An ordinary task/time reschedule publishes the staged effective requirements if they differ from the saved scheduling hint. Submission overrides and durable activity changes take precedence over recipe and node declarations. Replaying directives only rebuilds in-memory state; it never unconditionally yields. Publication uses JobDB's payload revision for concurrency and preserves unrelated client JSON. No separate checkpoints or demand revision are needed.

Stop or redirect an incompatible worker after OnHandoff to avoid a tight reacquisition loop. The event is a handoff, not completion. Admission errors stop keepalive for rejected leases; ordinary lease-expiry recovery applies.

Use ops.SuspendExecution at a successful durable activity boundary to request a change. Read-only replay must use ReadOnlyReplay: true and must not publish. See the design and user guide for lifecycle and failure semantics.

Supplied leases

Runtime.RunWithLease(ctx, lease, request, listener) uses JobDB's supplied-lease runner and checks live tasks after authoritative lease validation/renewal. It never calls acquisition APIs. Keep the same StageExecution, WrapTaskWorker, allocation, and callback wiring described above. The method returns after one lease lifecycle, including a normal reschedule or handoff.

Renewable lease wrappers retain shared invocation state across refreshed snapshots, so a heartbeat cannot drop staged requirements before rescheduling. They forward current token, owner, expiry, and schema metadata. See the run-with-lease guide for usage and deployment details.

Documentation

Overview

Package executionruntime checks actual executor compatibility before live tasks and carries resolved demand through ordinary workflow reschedules. It does not change JobDB's lease selection or add a separate persistence store.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Runtime

type Runtime struct {
	jobdb.WorkflowRuntime
	// Issuer translates recipe grants into task-scoped delegation requests.
	Issuer     permissions.Issuer
	Allocation execution.Allocation
	// contains filtered or unexported fields
}

func New

func New(runtime jobdb.WorkflowRuntime, allocation execution.Allocation) *Runtime

func (*Runtime) CreateDelegation added in v0.0.93

CreateDelegation forwards the optional runtime capability hidden by embedding WorkflowRuntime. Preserve the exact parent chosen by the engine and unwrap our admission wrapper so the remote runtime can export its original capability.

func (*Runtime) GetJobLease

func (*Runtime) PollWork

func (*Runtime) RunWithLease added in v0.0.56

RunWithLease executes exactly one supplied lease using JobDB's shared runner. It validates and renews before application work, and never acquires replacement work. Configure the recipe worker with this runtime's Stage and WrapTaskWorker, as for ordinary claim-and-run execution. Allocation checks use context Yield so acceptance is reported in the outcome. WorkerID should normally be left empty to retain the supplied lease owner.

func (*Runtime) Stage

func (r *Runtime) Stage(key jobdb.JobKey, demand execution.Demand)

func (*Runtime) WrapTaskWorker

func (r *Runtime) WrapTaskWorker(worker jobworkflow.TaskWorker) jobworkflow.TaskWorker

WrapTaskWorker checks needs only when JobDB actually invokes a task worker, after looking up completed results. Use it for every worker in the workset.

Jump to

Keyboard shortcuts

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