Pekko Runtime
PekkoRuntime leverages Pekko Persistence and Cluster Sharding to provide a distributed runtime for workflows.
PekkoRuntime operates natively with scala.concurrent.Future — your workflow context should declare type Effect[T] = Future[T]
or lift the desired effect as described in effect types.
"org.business4s" %% "workflows4s-pekko" % "0.6.0"
Example
Here is an example of using PekkoRuntime in a workflow:
import MyWorkflowCtx.*
given ActorSystem[?] = ???
val engine: WorkflowInstanceEngine[Future, Ctx] = ???
val workflow: WIO.Initial = ???
val runtime: PekkoRuntime[Ctx] = PekkoRuntime.create("my-workflow", workflow, InitialState(), engine)
runtime.initializeShard()
val instance: WorkflowInstance[Future, State] = runtime.createInstance_("my-workflow-id")
Caveats
While PekkoRuntime offers robust distributed capabilities, it comes with some caveats:
- Configuration Complexity:
- A significant amount of complexity is encapsulated within Pekko.
- Proper configuration is essential to ensure smooth operation.
- Initial State Limitation:
- Unlike other runtimes,
PekkoRuntimedoes not support arbitrary initial states during workflow instance creation. Initial state has to be build uniformly across all instances based onEntityContext.
- Unlike other runtimes,
- Shard Initialization:
- The
initializeShardmethod must be invoked before creating workflow instances to ensure proper setup.
- The