Signals allow you to trigger events in a workflow from outside the workflow. This can be useful for reacting to external events or for signaling the completion of an external task.
Queries allow you to retrieve information about the current state of a workflow without affecting its execution. This is useful for monitoring and debugging purposes.
Laravel Workflow provides the ability to suspend the execution of a workflow and resume at a later time. This can be useful for implementing delays, retry logic, or timeouts.
📄️ Signal + Timer
In some cases, you may want to wait for a signal or for a timer to expire, whichever comes first. This can be achieved by using WorkflowStub::awaitWithTimeout($seconds, $callback).
Heartbeats are sent at regular intervals to indicate that an activity is still running and hasn't frozen or crashed. They prevent the activity from being terminated due to timing out. This enables long-running activities to have a relatively low timeout. As long as the activity sends a heartbeat faster than the timeout duration, it will not be terminated.
📄️ Side Effects
A side effect is a closure containing non-deterministic code. The closure is only executed once and the result is saved. It will not execute again if the workflow is retried. Instead, it will return the saved result.
📄️ Child Workflows
It's often necessary to break down complex processes into smaller, more manageable units. Child workflows provide a way to encapsulate a sub-process within a parent workflow. This allows you to create hierarchical and modular structures for your workflows, making them more organized and maintainable.
Activities can be executed in series or in parallel. In either case, you start by using ActivityStub::all() method to wait for a group of activities to complete in parallel.
Sagas are an established design pattern for managing complex, long-running operations:
In Laravel Workflow, events are dispatched at various stages of workflow and activity execution to notify of progress, completion, or failures. These events can be used for logging, metrics collection, or any custom application logic.