Interface: Handlers<S>
Defined in: sdk/ts/sdk/src/core/workflow.ts:19
One pure handler per ReducerEvent type. Each receives the current state and the event and returns a Reduction. A run receiving an event with no handler fails.
Type Parameters
S
S
Methods
child_done()?
optionalchild_done(state,event):Reduction<S>
Defined in: sdk/ts/sdk/src/core/workflow.ts:29
A child run started by cmd.spawn closed.
Parameters
state
S
event
child_run_id
string
The child's run id.
output?
The child's output; present when it completed.
random
string
32 hex chars of journaled randomness.
status
succeeded, failed or cancelled, mapped from the child's run status.
step_id
string
Step id of the spawn.
ts_ms
number
Journaled event time, epoch milliseconds.
type
"child_done"
A child run closed.
usage_total
The run's banked usage including this event.
Returns
Reduction<S>
signal()?
optionalsignal(state,event):Reduction<S>
Defined in: sdk/ts/sdk/src/core/workflow.ts:25
A signal the run was waiting on was delivered.
Parameters
state
S
event
name
string
Signal name.
payload
Validated payload.
random
string
32 hex chars of journaled randomness.
step_id
string
Step id of the wait.
ts_ms
number
Journaled event time, epoch milliseconds.
type
"signal"
A signal the run was waiting on was delivered.
usage_total
The run's banked usage including this event.
Returns
Reduction<S>
started()
started(
state,event):Reduction<S>
Defined in: sdk/ts/sdk/src/core/workflow.ts:21
The first event of a run: state is what init built from the start input.
Parameters
state
S
event
input
The start input, as given to init.
random
string
32 hex chars of journaled randomness — the reducer's only entropy.
ts_ms
number
Journaled event time, epoch milliseconds — the reducer's only clock.
type
"started"
The run's first event.
usage_total
The run's banked usage including this event.
Returns
Reduction<S>
task_done()
task_done(
state,event):Reduction<S>
Defined in: sdk/ts/sdk/src/core/workflow.ts:23
A task reached a terminal status; event.output is set when it succeeded.
Parameters
state
S
event
activity
string
Activity name.
attempt
number
The attempt that produced this result.
cause?
Why it did not succeed.
error?
string
Error message from the worker or host.
output?
Validated output; present when succeeded.
random
string
32 hex chars of journaled randomness.
status
succeeded, failed or cancelled.
step_id
string
Step id of the task.
ts_ms
number
Journaled event time, epoch milliseconds.
type
"task_done"
A task reached a terminal status.
usage
What this attempt itself consumed; zeroed when the worker reported none.
usage_total
The run's banked usage including this event.
Returns
Reduction<S>
timer()?
optionaltimer(state,event):Reduction<S>
Defined in: sdk/ts/sdk/src/core/workflow.ts:27
A timer opened by cmd.timer fired.
Parameters
state
S
event
random
string
32 hex chars of journaled randomness.
step_id
string
Step id of the timer.
ts_ms
number
Journaled event time, epoch milliseconds.
type
"timer"
A timer fired.
usage_total
The run's banked usage including this event.
Returns
Reduction<S>