You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// 2. **Specify the handler** you want to call and supply the request.
310
310
/// 3. **Await** the call to retrieve the response.
311
311
///
312
-
/// **Tip: No need for manual retry logic**:
313
-
/// These calls are proxied by Restate, and get logged in the journal.
314
-
/// In case of failures, Restate takes care of retries.
315
-
///
316
-
/// **Note: Workflow retention time**:
317
-
/// Once the `run` handler of the workflow has finished, the other handlers can still be called up to the retention time of the workflow, by default 24 hours.
318
-
/// This 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`.
319
-
///
320
-
/// **Caution: Deadlocks with Virtual Objects**:
321
-
/// Request-response calls to Virtual Objects can lead to deadlocks, in which the Virtual Object remains locked and can't process any more requests.
322
-
/// Some example cases:
323
-
/// - Cross deadlock between Virtual Object A and B: A calls B, and B calls A, both using same keys.
324
-
/// - Cyclical deadlock: A calls B, and B calls C, and C calls A again.
325
-
///
326
-
/// In this situation, you can use the CLI to unblock the Virtual Object manually by [cancelling invocations](https://docs.restate.dev/operate/invocation#cancelling-invocations).
312
+
/// **No need for manual retry logic**:
313
+
/// Restate proxies all the calls and logs them in the journal.
314
+
/// In case of failures, Restate takes care of retries, so you don't need to implement this yourself here.
/// It is guaranteed that call A will execute before call B.
429
416
/// It is not guaranteed though that call B will be executed immediately after call A, as invocations coming from other handlers/sources, could interleave these two calls.
417
+
///
418
+
/// ### Deadlocks with Virtual Objects
419
+
/// Request-response calls to Virtual Objects can lead to deadlocks, in which the Virtual Object remains locked and can't process any more requests.
420
+
/// Some example cases:
421
+
/// - Cross deadlock between Virtual Object A and B: A calls B, and B calls A, both using same keys.
422
+
/// - Cyclical deadlock: A calls B, and B calls C, and C calls A again.
423
+
///
424
+
/// In this situation, you can use the CLI to unblock the Virtual Object manually by [cancelling invocations](https://docs.restate.dev/operate/invocation#cancelling-invocations).
/// **Note**: You can return any payload that implements the `serde::Serialize` and `serde::Deserialize` traits ([see serialization docs][crate::serde]).
618
+
/// You can return any payload that implements the `serde::Serialize` and `serde::Deserialize` traits ([see serialization docs][crate::serde]).
623
619
///
624
-
/// **Note**: When running on Function-as-a-Service platforms, such as AWS Lambda, Restate suspends the handler while waiting for the awakeable to be completed.
620
+
/// When running on Function-as-a-Service platforms, such as AWS Lambda, Restate suspends the handler while waiting for the awakeable to be completed.
625
621
/// Since you only pay for the time that the handler is actually running, you don't pay while waiting for the external process to return.
626
622
///
627
-
/// **Warning**: Virtual Objects only process a single invocation at a time, so the Virtual Object will be blocked while waiting on the awakeable to be resolved.
623
+
/// **Be aware**: Virtual Objects only process a single invocation at a time, so the Virtual Object will be blocked while waiting on the awakeable to be resolved.
/// This means that non-deterministic results (e.g. database responses, UUID generation) need to be stored in the execution log.
656
652
/// The SDK offers some functionalities to help you with this:
657
653
/// 1. **[Journaled actions][crate::context::ContextSideEffects#journaled-actions]**: Run any block of code and store the result in Restate. Restate replays the result instead of re-executing the block on retries.
658
-
/// 3. **[Random generators][crate::context::ContextSideEffects#generating-randoms]**: Built-in helpers for generating stable UUIDs and random numbers.
659
-
///
660
-
/// ## Journaled actions
661
-
/// You can store the result of a (non-deterministic) operation in the Restate execution log (e.g. database requests, HTTP calls, etc).
662
-
/// Restate replays the result instead of re-executing the operation on retries.
663
-
///
664
-
/// Here is an example of a database request for which the string response is stored in Restate:
/// Always immediately await `ctx.run`, before doing any other context calls.
683
-
/// If not, you might bump into non-determinism errors during replay,
684
-
/// because the journaled result can get interleaved with the other context calls in the journal in a non-deterministic way.
685
-
///
654
+
/// 2. **[UUID generator][crate::context::ContextSideEffects#generating-uuids]**: Built-in helpers for generating stable UUIDs. Restate seeds the random number generator with the invocation ID, so it always returns the same value on retries.
655
+
/// 3. **[Random generator][crate::context::ContextSideEffects#generating-random-numbers]**: Built-in helpers for generating randoms. Restate seeds the random number generator with the invocation ID, so it always returns the same value on retries.
686
656
///
687
-
/// ## Generating randoms
688
-
/// The SDK provides helper functions for the deterministic generation of UUIDs and random numbers. Restate seeds the random number generator with the invocation ID, so it always returns the same value on retries.
689
-
///
690
-
/// ### Generating UUIDs
691
-
///
692
-
/// You can use these UUIDs to generate stable idempotency keys, to deduplicate operations. For example, you can use this to let a payment service avoid duplicate payments during retries.
/// This instance is useful to generate identifiers, idempotency keys, and for uniform sampling from a set of options.
739
716
/// If a cryptographically secure value is needed, please generate that externally using [`ContextSideEffects::run`].
740
717
#[cfg(feature = "rand")]
741
718
fnrand(&mutself) -> &mut rand::prelude::StdRng{
742
719
private::SealedContext::rand(self)
743
720
}
744
-
745
-
/// Return a random [`uuid::Uuid`], generated using [`ContextSideEffects::rand`].
721
+
/// ### Generating UUIDs
722
+
///
723
+
/// Returns a random [`uuid::Uuid`], generated using [`ContextSideEffects::rand`].
724
+
///
725
+
/// You can use these UUIDs to generate stable idempotency keys, to deduplicate operations. For example, you can use this to let a payment service avoid duplicate payments during retries.
/// Restate makes sure the state is consistent with the processing of the code execution.
758
748
///
759
749
/// **This feature is only available for Virtual Objects and Workflows:**
760
750
/// - For **Virtual Objects**, the state is isolated per Virtual Object and lives forever (across invocations for that object).
761
751
/// - For **Workflows**, you can think of it as if every workflow execution is a new object. So the state is isolated to a single workflow execution. The state can only be mutated by the `run` handler of the workflow. The other handlers can only read the state.
762
752
///
763
-
/// **Info: Command-line introspection**:
764
-
/// You can inspect and edit the K/V state stored in Restate via `psql` and the CLI.
765
-
/// Have a look at the [introspection docs](https://docs.restate.dev//operate/introspection#inspecting-application-state) for more information.
766
-
///
767
-
/// **Info: Serializing state**:
768
-
/// You can store any type of value that that implements the `serde::Serialize` and `serde::Deserialize` traits ([see serialization docs][crate::serde]).
/// You can inspect and edit the K/V state stored in Restate via `psql` and the CLI.
783
+
/// Have a look at the [introspection docs](https://docs.restate.dev//operate/introspection#inspecting-application-state) for more information.
784
+
///
785
+
/// ### Serializing state
786
+
/// You can store any type of value that that implements the `serde::Serialize` and `serde::Deserialize` traits ([see serialization docs][crate::serde]).
/// Restate makes sure the state is consistent with the processing of the code execution.
821
811
///
822
812
/// **This feature is only available for Virtual Objects and Workflows:**
823
813
/// - For **Virtual Objects**, the state is isolated per Virtual Object and lives forever (across invocations for that object).
824
814
/// - For **Workflows**, you can think of it as if every workflow execution is a new object. So the state is isolated to a single workflow execution. The state can only be mutated by the `run` handler of the workflow. The other handlers can only read the state.
825
815
///
826
-
/// **Info: Command-line introspection**:
827
-
/// You can inspect and edit the K/V state stored in Restate via `psql` and the CLI.
828
-
/// Have a look at the [introspection docs](https://docs.restate.dev//operate/introspection#inspecting-application-state) for more information.
829
-
///
830
-
/// **Info: Serializing state**:
831
-
/// You can store any type of value that that implements the `serde::Serialize` and `serde::Deserialize` traits ([see serialization docs][crate::serde]).
/// You can inspect and edit the K/V state stored in Restate via `psql` and the CLI.
846
+
/// Have a look at the [introspection docs](https://docs.restate.dev//operate/introspection#inspecting-application-state) for more information.
847
+
///
848
+
/// ### Serializing state
849
+
/// You can store any type of value that that implements the `serde::Serialize` and `serde::Deserialize` traits ([see serialization docs][crate::serde]).
0 commit comments