Interface WorkflowEntrypoint
Name the class with workflows(...) and the build writes the JavaScript
WorkflowEntrypoint subclass the platform instantiates, and the binding that starts it.
Each invocation of run(dev.gmitch215.bytebox.workflow.WorkflowEvent, dev.gmitch215.bytebox.workflow.Step, dev.gmitch215.bytebox.Env) gets a new instance of this class.
The platform replays run from the top to resume an instance, and a step it has already
finished returns its saved result without running its body. Everything outside a step runs again
on every resume, so keep side effects, the clock and randomness inside Step.run(java.lang.String, java.util.concurrent.Callable<dev.gmitch215.bytebox.js.TSObject>) and name
steps the same way every time. Fields do not survive a resume, because the instance can be
rebuilt in a fresh isolate.
public class Onboarding implements WorkflowEntrypoint {
@Override
public TSObject run(WorkflowEvent event, Step step, Env env) {
String id = event.payload().get("id").asString();
TSObject user = step.run("load user", () -> env.kv().getJson(id));
step.sleep("wait a day", "1 day");
return step.run("greet", () -> TSObject.of("welcome " + user.get("name").asString()));
}
}
- Since:
- 1.0.3
-
Method Summary
Modifier and TypeMethodDescriptionrun(WorkflowEvent event, Step step, Env env) Runs one instance.
-
Method Details
-
run
Runs one instance.- Parameters:
event- what started the instancestep- the durable stepsenv- the bindings- Returns:
- the instance's output, visible through
Instance.status(); may benull
-