Throwing Workflow Events
info
Before you can add a THROW_EVENT
Node to a WfSpec
, you need to create a WorkflowEventDef
metadata object in LittleHorse representing the event you want to throw. You can do that following our metadata management docs.
To throw a WorkflowEvent in LittleHorse, you must define a THROW_EVENT
Node in a WfSpec
.
Defining a THROW_EVENT
Node
The following code defines a workflow that waits 5 seconds before throwing a WorkflowEvent
named "my-event", with the content "Hello There!".
- Java
- Python
- Go
public static Workflow getWorkflow() {
return Workflow.newWorkflow(
"throw-wf-event",
wf -> {
wf.sleepSeconds(5);
wf.throwEvent("my-event", "Hello There!");
});
}
def get_workflow() -> Workflow:
def my_entrypoint(wf: WorkflowThread) -> None:
wf.sleep(5)
wf.throwEvent("sleep-done", "Hello There!")
return Workflow("throw-wf-event", my_entrypoint)
func ThrowWfEvent(wf *littlehorse.WorkflowThread) {
wf.Sleep(5)
wf.ThrowEvent("my-event", "Hello there!")
}
Required Parameters
The two required values are:
workflowEventDefName
is the Name of theWorkflowEventDef
that you want to throw aWorkflowEvent
for.content
is the content of theWorkflowEvent
that will be stored in thecontent
field of theWorkflowEvent
. Content type will match theVariableType
specified in yourWorkflowEventDef
.