Package kalix.javasdk.workflowentity
Class WorkflowEntity<S>
Object
kalix.javasdk.workflowentity.WorkflowEntity<S>
- Type Parameters:
S- The type of the state for this entity.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic interfaceA return type to allow returning failures or attaching effects to messages.static classstatic interfacestatic classstatic classstatic class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid_internalSetCommandContext(Optional<CommandContext> context) INTERNAL APIvoid_internalSetCurrentState(S state) INTERNAL APIprotected final CommandContextAdditional context and metadata for a command handler.protected final SReturns the state as currently stored by Kalix.abstract WorkflowEntity.Workflow<S>protected final WorkflowEntity.Effect.Builder<S>effects()Returns the initial empty state object.static WorkflowEntity.StepBuilderStart a step definition with a given step name.workflow()
-
Constructor Details
-
WorkflowEntity
public WorkflowEntity()
-
-
Method Details
-
emptyState
Returns the initial empty state object. This object will be passed into the command and step handlers, until a new state replaces it.Also known as "zero state" or "neutral state".
The default implementation of this method returns
null. It can be overridden to return a more sensible initial state. -
commandContext
Additional context and metadata for a command handler.It will throw an exception if accessed from constructor.
- Throws:
IllegalStateException- if accessed outside a handler method
-
_internalSetCommandContext
INTERNAL API -
_internalSetCurrentState
INTERNAL API -
currentState
Returns the state as currently stored by Kalix.Note that modifying the state directly will not update it in storage. To save the state, one must call {
effects().updateState()}.This method can only be called when handling a command. Calling it outside a method (eg: in the constructor) will raise a IllegalStateException exception.
- Throws:
IllegalStateException- if accessed outside a handler method
-
definition
- Returns:
- A workflow definition in a form of steps and transitions between them.
-
effects
-
workflow
-
step
Start a step definition with a given step name.- Parameters:
name- Step name.- Returns:
- Step builder.
-