aion/activity
Typed activity values and policy configuration.
Types
A typed activity invocation value.
i is the statically-known input type and o is the statically-known output
type. The input and output codecs are carried so workflow dispatch can encode
the author value and decode the type-erased engine payload without
reflection.
pub opaque type Activity(i, o)
Backoff strategy carried with an explicit retry policy.
The SDK only stores this configuration for the engine to interpret during dispatch. It does not apply retries or invent missing timing values.
pub type Backoff {
Exponential(
initial: duration.Duration,
multiplier: Float,
max: duration.Duration,
)
Linear(
initial: duration.Duration,
increment: duration.Duration,
max: duration.Duration,
)
Fixed(delay: duration.Duration)
}
Constructors
-
Exponential( initial: duration.Duration, multiplier: Float, max: duration.Duration, )Exponential backoff from
initial, scaled bymultiplier, capped atmax. -
Linear( initial: duration.Duration, increment: duration.Duration, max: duration.Duration, )Linear backoff from
initial, addingincrement, capped atmax. -
Fixed(delay: duration.Duration)Fixed backoff with the same
delaybetween attempts.
Explicit retry policy for an activity.
No default retry policy is baked into the SDK. An activity built with new
and no retry decorator carries no policy and runs exactly once when the
engine dispatches it.
pub type RetryPolicy {
RetryPolicy(max_attempts: Int, backoff: Backoff)
}
Constructors
-
RetryPolicy(max_attempts: Int, backoff: Backoff)
Values
pub fn heartbeat(
activity: Activity(i, o),
heartbeat_interval: duration.Duration,
) -> Activity(i, o)
Attach an explicit heartbeat interval to an activity.
pub fn heartbeat_interval(
activity: Activity(i, o),
) -> option.Option(duration.Duration)
Return the explicitly attached heartbeat interval, if one exists.
pub fn input(activity: Activity(i, o)) -> i
Return the typed input captured by the activity value.
pub fn input_codec(activity: Activity(i, o)) -> codec.Codec(i)
Return the typed input codec captured by the activity value.
pub fn name(activity: Activity(i, o)) -> String
Return the activity name used by the engine dispatch boundary.
pub fn new(
name: String,
input: i,
input_codec: codec.Codec(i),
output_codec: codec.Codec(o),
run: fn(i) -> Result(o, error.ActivityError),
) -> Activity(i, o)
Build a typed activity value with no retry, timeout, or heartbeat config.
Absence of config is intentional data: there are no hidden defaults. In
particular, an activity with no retry decorator runs exactly once when it
is dispatched by the engine.
pub fn output_codec(activity: Activity(i, o)) -> codec.Codec(o)
Return the typed output codec captured by the activity value.
pub fn retry(
activity: Activity(i, o),
policy: RetryPolicy,
) -> Activity(i, o)
Attach an explicit retry policy to an activity.
Later calls replace earlier retry policy values; the SDK does not merge or synthesize policy fields.
pub fn retry_policy(
activity: Activity(i, o),
) -> option.Option(RetryPolicy)
Return the explicitly attached retry policy, if one exists.
pub fn runner(
activity: Activity(i, o),
) -> fn(i) -> Result(o, error.ActivityError)
Return the typed runner captured by the activity value.
pub fn timeout(
activity: Activity(i, o),
timeout_duration: duration.Duration,
) -> Activity(i, o)
Attach an explicit timeout duration to an activity.
pub fn timeout_duration(
activity: Activity(i, o),
) -> option.Option(duration.Duration)
Return the explicitly attached timeout duration, if one exists.