Package io.littlehorse.sdk.wfsdk
Class Workflow
- java.lang.Object
-
- io.littlehorse.sdk.wfsdk.Workflow
-
public abstract class Workflow extends java.lang.ObjectThe Workflow class represents a `WfSpec` object in the API.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidcompileAndSaveToDisk(java.lang.String directory)Writes out all PutTaskDefPb, PutExternalEventDefPb, and PutWfSpecPb in JSON form in a directory.abstract java.util.Set<io.littlehorse.sdk.common.proto.PutTaskDefPb>compileTaskDefs()Creates a set of all TaskDef's that need to be created for this WfSpec, determined by calls to ThreadBuilder::executeAndRegisterTaskDef().java.util.List<java.lang.String>compileTaskDefsToJson()Creates a list of all TaskDef's that need to be created for this WfSpec, determined by calls to ThreadBuilder::executeAndRegisterTaskDef().java.lang.StringcompileWfToJson()Returns the associated PutWfSpecPb in JSON form.abstract io.littlehorse.sdk.common.proto.PutWfSpecPbcompileWorkflow()Compiles this Workflow into a `WfSpec`.booleandoesWfSpecExist(LHClient client)Checks if the WfSpec existsbooleandoesWfSpecExist(LHClient client, java.lang.Integer version)Checks if the WfSpec exists for a given versionjava.lang.StringgetName()Gets the workflow name passed atnewWorkflow(String, ThreadFunc)abstract java.util.Set<java.lang.String>getRequiredExternalEventDefNames()Returns the names of all `ExternalEventDef`s used by this workflow.abstract java.util.Set<java.lang.String>getRequiredTaskDefNames()Returns the names of all `TaskDef`s used by this workflow.abstract java.util.Set<java.lang.Object>getTaskExecutables()Returns a set of all objects that were passed to executeAndRegisterTaskDef().static WorkflownewWorkflow(java.lang.String name, ThreadFunc entrypointThreadFunc)Creates a new Workflow with the provided name and entrypoint thread function.voidregisterWfSpec(LHClient client)Deploys the WfSpec object to the LH Server.voidwithRetentionHours(int retentionHours)Add the hours of life that the workflow will have in the system
-
-
-
Method Detail
-
getName
public java.lang.String getName()
Gets the workflow name passed atnewWorkflow(String, ThreadFunc)- Returns:
- the Workflow name
-
withRetentionHours
public void withRetentionHours(int retentionHours)
Add the hours of life that the workflow will have in the system- Parameters:
retentionHours- are the hours in which the workflow will live in the system
-
newWorkflow
public static Workflow newWorkflow(java.lang.String name, ThreadFunc entrypointThreadFunc)
Creates a new Workflow with the provided name and entrypoint thread function.- Parameters:
name- is the name of the `WfSpec`.entrypointThreadFunc- is the ThreadFunc for the entrypoint ThreadSpec.- Returns:
- a Workflow.
-
compileWorkflow
public abstract io.littlehorse.sdk.common.proto.PutWfSpecPb compileWorkflow()
Compiles this Workflow into a `WfSpec`.- Returns:
- a `PutWfSpecPb` that can be used for the gRPC putWfSpec() call.
-
compileTaskDefs
public abstract java.util.Set<io.littlehorse.sdk.common.proto.PutTaskDefPb> compileTaskDefs()
Creates a set of all TaskDef's that need to be created for this WfSpec, determined by calls to ThreadBuilder::executeAndRegisterTaskDef().- Returns:
- a Set of PutTaskDefPbs containing a PutTaskDef for every auto-generated TaskDef in this `WfSpec`.
-
getRequiredTaskDefNames
public abstract java.util.Set<java.lang.String> getRequiredTaskDefNames()
Returns the names of all `TaskDef`s used by this workflow.- Returns:
- a Set of Strings containing the names of all `TaskDef`s used by this workflow.
-
getTaskExecutables
public abstract java.util.Set<java.lang.Object> getTaskExecutables()
Returns a set of all objects that were passed to executeAndRegisterTaskDef().- Returns:
- a set of all Task Worker objects that were passed into ThreadBuilder::executeAndRegisterTaskDef().
-
getRequiredExternalEventDefNames
public abstract java.util.Set<java.lang.String> getRequiredExternalEventDefNames()
Returns the names of all `ExternalEventDef`s used by this workflow. Includes ExternalEventDefs used for Interrupts or for EXTERNAL_EVENT nodes.- Returns:
- a Set of Strings containing the names of all `ExternalEventDef`s used by this workflow.
-
compileWfToJson
public java.lang.String compileWfToJson()
Returns the associated PutWfSpecPb in JSON form.- Returns:
- the associated PutWfSpecPb in JSON form.
-
compileTaskDefsToJson
public java.util.List<java.lang.String> compileTaskDefsToJson()
Creates a list of all TaskDef's that need to be created for this WfSpec, determined by calls to ThreadBuilder::executeAndRegisterTaskDef().- Returns:
- a List containing the containing a PutTaskDef in Json form (String) for every auto-generated TaskDef in this `WfSpec`.
-
doesWfSpecExist
public boolean doesWfSpecExist(LHClient client) throws io.littlehorse.sdk.common.exception.LHApiError
Checks if the WfSpec exists- Parameters:
client- is an LHClient.- Returns:
- true if the workflow spec is registered or false otherwise
- Throws:
io.littlehorse.sdk.common.exception.LHApiError- if the call fails.
-
doesWfSpecExist
public boolean doesWfSpecExist(LHClient client, java.lang.Integer version) throws io.littlehorse.sdk.common.exception.LHApiError
Checks if the WfSpec exists for a given version- Parameters:
client- is an LHClient.version- workflow version- Returns:
- true if the workflow spec is registered for this version or false otherwise
- Throws:
io.littlehorse.sdk.common.exception.LHApiError
-
registerWfSpec
public void registerWfSpec(LHClient client) throws io.littlehorse.sdk.common.exception.LHApiError
Deploys the WfSpec object to the LH Server. Registering the WfSpec via Workflow::registerWfSpec() is the same as client.putWfSpec(workflow.compileWorkflow()).- Parameters:
client- is an LHClient.- Throws:
io.littlehorse.sdk.common.exception.LHApiError- if the call fails.
-
compileAndSaveToDisk
public void compileAndSaveToDisk(java.lang.String directory)
Writes out all PutTaskDefPb, PutExternalEventDefPb, and PutWfSpecPb in JSON form in a directory.- Parameters:
directory- is the location to save the resources.
-
-