|
59 | 59 | //! |
60 | 60 | //! - Specify that you want to create a service by using the [`#[restate_sdk::service]` macro](restate_sdk_macros::service). |
61 | 61 | //! - Create a trait with the service handlers. |
62 | | -//! - Handlers can accept zero or one parameter and return a `Result`. |
63 | | -//! - The type of the input parameter of the handler needs to implement [`Serialize`](crate::serde::Deserialize) and [`Deserialize`](crate::serde::Deserialize). See [Serialization docs](crate::serde). |
64 | | -//! - The Result contains the return value or a [`HandlerError`][crate::errors::HandlerError], which can be a [`TerminalError`] or any other Rust's `StdError`. |
| 62 | +//! - Handlers can accept zero or one parameter and return a [`Result`]. |
| 63 | +//! - The type of the input parameter of the handler needs to implement [`Serialize`](crate::serde::Deserialize) and [`Deserialize`](crate::serde::Deserialize). See [`crate::serde`]. |
| 64 | +//! - The Result contains the return value or a [`HandlerError`][crate::errors::HandlerError], which can be a [`TerminalError`](crate::errors::TerminalError) or any other Rust's [`std::error::Error`]. |
65 | 65 | //! - The service handler can now be called at `<RESTATE_INGRESS_URL>/MyService/myHandler`. You can optionally override the handler name used via `#[name = "myHandler"]`. More details on handler invocations can be found in the [docs](https://docs.restate.dev/invoke/http). |
66 | | -//! - Implement the trait on a struct. The struct will contain the actual implementation of the handlers. |
| 66 | +//! - Implement the trait on a concrete type, for example on a struct. |
67 | 67 | //! - The first parameter of a handler after `&self` is always a [`Context`](crate::context::Context) to interact with Restate. |
68 | 68 | //! The SDK stores the actions you do on the context in the Restate journal to make them durable. |
69 | 69 | //! - Finally, create an HTTP endpoint and bind the service(s) to it. Listen on the specified port (here 9080) for connections and requests. |
|
117 | 117 | //! |
118 | 118 | //! - Specify that you want to create a Virtual Object by using the [`#[restate_sdk::object]` macro](restate_sdk_macros::object). |
119 | 119 | //! - The first argument of each handler must be the [`ObjectContext`](crate::context::ObjectContext) parameter. Handlers with the `ObjectContext` parameter can write to the K/V state store. Only one handler can be active at a time per object, to ensure consistency. |
120 | | -//! - You can retrieve the key of the object you are in via `ctx.key()`. |
| 120 | +//! - You can retrieve the key of the object you are in via [`ObjectContext.key`]. |
121 | 121 | //! - If you want to have a handler that executes concurrently to the others and doesn't have write access to the K/V state, add `#[shared]` to the handler definition in the trait. |
122 | 122 | //! Shared handlers need to use the [`SharedObjectContext`](crate::context::SharedObjectContext). |
123 | 123 | //! You can use these handlers, for example, to read K/V state and expose it to the outside world, or to interact with the blocking handler and resolve awakeables etc. |
|
0 commit comments