Skip to content

Commit b415fd2

Browse files
authored
Improve workflow docs (#40)
* Improve workflow docs * Improve workflow docs * Format
1 parent 28e4c2e commit b415fd2

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

src/lib.rs

+17-9
Original file line numberDiff line numberDiff line change
@@ -349,18 +349,26 @@ pub use restate_sdk_macros::object;
349349
///
350350
/// Entry-point macro to define a Restate [Workflow](https://docs.restate.dev/concepts/services#workflows).
351351
///
352-
/// Workflows are a sequence of steps that gets executed durably.
353-
/// A workflow can be seen as a special type of [Virtual Object](https://docs.restate.dev/concepts/services#virtual-objects) with some special characteristics:
354-
///
355-
/// - Each workflow definition has a `run` handler that implements the workflow logic.
356-
/// - The `run` handler executes exactly one time for each workflow instance (object / key).
357-
/// - A workflow definition can implement other handlers that can be called multiple times, and can interact with the workflow.
358-
/// - Workflows have access to the `WorkflowContext` and `SharedWorkflowContext`, giving them some extra functionality, for example Durable Promises to signal workflows.
352+
/// [Workflows](https://docs.restate.dev/concepts/services#workflows) are a sequence of steps that gets executed durably.
353+
///
354+
/// A workflow can be seen as a special type of [Virtual Object](https://docs.restate.dev/concepts/services#virtual-objects) with the following characteristics:
355+
///
356+
/// - Each workflow definition has a **`run` handler** that implements the workflow logic.
357+
/// - The `run` handler **executes exactly one time** for each workflow instance (object / key).
358+
/// - The `run` handler executes a set of **durable steps/activities**. These can either be:
359+
/// - Inline activities: for example a [run block](crate::context::ContextSideEffects) or [sleep](crate::context::ContextTimers)
360+
/// - [Calls to other handlers](crate::context::ContextClient) implementing the activities
361+
/// - You can **submit a workflow** in the same way as any handler invocation (via SDK clients or Restate services, over HTTP or Kafka).
362+
/// - A workflow definition can implement other handlers that can be called multiple times, and can **interact with the workflow**:
363+
/// - Query the workflow (get information out of it) by getting K/V state or awaiting promises that are resolved by the workflow.
364+
/// - Signal the workflow (send information to it) by resolving promises that the workflow waits on.
365+
/// - Workflows have access to the [`WorkflowContext`](crate::context::WorkflowContext) and [`SharedWorkflowContext`](crate::context::SharedWorkflowContext), giving them some extra functionality, for example [Durable Promises](#signaling-workflows) to signal workflows.
366+
/// - The K/V state of the workflow is isolated to the workflow execution, and can only be mutated by the `run` handler.
359367
///
360368
/// **Note: Workflow retention time**:
361369
/// The retention time of a workflow execution is 24 hours after the finishing of the `run` handler.
362370
/// After this timeout any [K/V state][crate::context::ContextReadState] is cleared, the workflow's shared handlers cannot be called anymore, and the Durable Promises are discarded.
363-
/// The retention time can be configured via the [Admin API](https://docs.restate.dev//references/admin-api/#tag/service/operation/modify_service) per Workflow definition by setting `workflow_completion_retention`.
371+
/// The retention time can be configured via the [Admin API](https://docs.restate.dev/references/admin-api/#tag/service/operation/modify_service) per Workflow definition by setting `workflow_completion_retention`.
364372
///
365373
/// ## Implementing workflows
366374
/// Have a look at the code example to get a better understanding of how workflows are implemented:
@@ -419,7 +427,7 @@ pub use restate_sdk_macros::object;
419427
/// Every workflow needs a `run` handler.
420428
/// This handler has access to the same SDK features as Service and Virtual Object handlers.
421429
/// In the example above, we use [`ctx.run`][crate::context::ContextSideEffects::run] to log the sending of the email in Restate and avoid re-execution on replay.
422-
///
430+
/// Or call other handlers to execute activities.
423431
///
424432
/// ## Shared handlers
425433
///

0 commit comments

Comments
 (0)