Documentation
¶
Overview ¶
Package execution defines typed activity contracts for workflow adapters. It does not own persistence, workflow scheduling, or application policy.
Index ¶
- type Activity
- func (a Activity[I, O]) Execute(ctx context.Context, executor ActivityExecutor, input I, opts ActivityOptions) (O, error)
- func (a Activity[I, O]) ExecuteAsync(ctx context.Context, executor ActivityExecutor, input I, opts ActivityOptions) (Future[O], error)
- func (a Activity[I, O]) Register(ctx context.Context, registrar ActivityRegistrar, opts ActivityOptions, ...) error
- type ActivityCall
- type ActivityDefinition
- type ActivityExecutor
- type ActivityFuture
- type ActivityOptions
- type ActivityRegistrar
- type Future
- type RetryPolicy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Activity ¶
type Activity[I, O any] struct { // Name must be stable across worker restarts and workflow replay. Name string }
Activity binds a stable activity name to its input and output types. Reusing the same value for registration and invocation keeps both ends typed.
func (Activity[I, O]) Execute ¶
func (a Activity[I, O]) Execute(ctx context.Context, executor ActivityExecutor, input I, opts ActivityOptions) (O, error)
Execute schedules the activity and waits for its typed result.
func (Activity[I, O]) ExecuteAsync ¶
func (a Activity[I, O]) ExecuteAsync(ctx context.Context, executor ActivityExecutor, input I, opts ActivityOptions) (Future[O], error)
ExecuteAsync schedules the activity without waiting for completion.
type ActivityCall ¶
type ActivityCall struct {
// Name identifies a registered activity.
Name string
// Input is passed to the backend codec without a wrapper envelope.
Input any
// Options overrides registration defaults according to backend rules.
Options ActivityOptions
}
ActivityCall carries a typed input unchanged to the backend's serializer.
type ActivityDefinition ¶
type ActivityDefinition struct {
// Name identifies the activity within its backend registry.
Name string
// Options supplies portable registration defaults.
Options ActivityOptions
// Handler must be func(context.Context, I) (O, error) or func(context.Context, I) error.
// Use Activity[I, O].Register for compile-time checking of input and output.
Handler any
}
ActivityDefinition describes an activity independently of agent payload types.
type ActivityExecutor ¶
type ActivityExecutor interface {
// ExecuteActivity schedules and waits for a result, decoded into a pointer.
ExecuteActivity(context.Context, ActivityCall, any) error
// ExecuteActivityAsync schedules a command in this executor's workflow scope.
ExecuteActivityAsync(context.Context, ActivityCall) (ActivityFuture, error)
}
ActivityExecutor schedules named activities in a workflow scope. Results must be decoded into the supplied pointer using the backend's codec.
type ActivityFuture ¶
type ActivityFuture interface {
// Get waits using the captured workflow scope and decodes into a pointer.
Get(context.Context, any) error
// IsReady reports completion without blocking.
IsReady() bool
}
ActivityFuture is the backend result boundary. Application code should use Activity[I, O], which exposes Future[O] instead of result pointers.
type ActivityOptions ¶
type ActivityOptions struct {
// Queue overrides the activity queue. Empty uses registration or backend defaults.
Queue string
// RetryPolicy controls retry behavior for this activity. If zero-valued, the
// engine uses its default retry policy.
RetryPolicy RetryPolicy
// ScheduleToStartTimeout bounds how long the activity may wait in the task
// queue before a worker starts the attempt. Zero means leave queue-wait
// unspecified here and let the engine adapter apply its own defaults.
ScheduleToStartTimeout time.Duration
// StartToCloseTimeout bounds one activity attempt once a worker has started
// executing it. Zero means use the engine default.
StartToCloseTimeout time.Duration
// HeartbeatTimeout bounds the maximum gap between heartbeats emitted by the
// running activity. Zero leaves the backend default unchanged.
HeartbeatTimeout time.Duration
}
ActivityOptions configures retry and timeouts for an activity.
type ActivityRegistrar ¶
type ActivityRegistrar interface {
// RegisterActivity validates and installs a concrete handler.
RegisterActivity(context.Context, ActivityDefinition) error
}
ActivityRegistrar installs activities before workers begin polling.
type Future ¶
type Future[T any] interface { // Get blocks until the activity completes and returns the typed result. // Once completed, repeated calls return the recorded result. Get(ctx context.Context) (T, error) // IsReady returns true if the activity has completed (success or failure) and Get() // will not block. This allows workflows to poll or implement custom waiting strategies. IsReady() bool }
Future represents a pending activity result. It belongs to the workflow execution that scheduled it and must not be shared across workflows. Waiting and cancellation follow the selected backend's rules.
type RetryPolicy ¶
type RetryPolicy struct {
// MaxAttempts caps total attempts, including the first. Zero uses backend defaults.
MaxAttempts int
// InitialInterval is the delay before the first retry. Zero means use engine default.
InitialInterval time.Duration
// BackoffCoefficient multiplies the delay after each retry. Zero uses backend
// defaults; the backend defines the valid range of explicit coefficients.
BackoffCoefficient float64
}
RetryPolicy defines retry semantics shared by workflows and activities. Zero-valued fields mean the engine uses its defaults.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package adapter implements the type-erased adapter boundary for typed activities.
|
Package adapter implements the type-erased adapter boundary for typed activities. |
|
Package selvedge binds execution activities to native Selvedge apps and workflow scopes.
|
Package selvedge binds execution activities to native Selvedge apps and workflow scopes. |