Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
658bb46 to
5599ed2
Compare
5599ed2 to
8ed93c7
Compare
adb4a7a to
3d673be
Compare
3d673be to
d6eb0bd
Compare
d6eb0bd to
bcd3c34
Compare
2cb46fa to
de03821
Compare
| let connection_options = | ||
| ConnectionOptions::new(Url::from_str("http://localhost:7233")?).build(); |
There was a problem hiding this comment.
It might make sense to funnel users towards envconfig:
https://github.com/temporalio/sdk-core/blob/00d3888adc36d4fab36cca3fdd8426c199ab669d/crates/sdk/examples/hello_world/worker.rs#L18
| #[activities] | ||
| impl GreetingActivities { | ||
| #[activity] | ||
| pub async fn greet(_ctx: ActivityContext, name: String) -> Result<String, ActivityError> { | ||
| Ok(format!("Hello, {}!", name)) | ||
| } | ||
|
|
||
| #[activity] | ||
| pub async fn send_notification(_ctx: ActivityContext, message: String) -> Result<(), ActivityError> { | ||
| println!("Sending notification: {}", message); | ||
| Ok(()) | ||
| } | ||
| } | ||
|
|
||
| pub struct GreetingActivities; |
There was a problem hiding this comment.
It is awkward to declare the struct after the implementation
| #[activities] | |
| impl GreetingActivities { | |
| #[activity] | |
| pub async fn greet(_ctx: ActivityContext, name: String) -> Result<String, ActivityError> { | |
| Ok(format!("Hello, {}!", name)) | |
| } | |
| #[activity] | |
| pub async fn send_notification(_ctx: ActivityContext, message: String) -> Result<(), ActivityError> { | |
| println!("Sending notification: {}", message); | |
| Ok(()) | |
| } | |
| } | |
| pub struct GreetingActivities; | |
| pub struct GreetingActivities; | |
| #[activities] | |
| impl GreetingActivities { | |
| #[activity] | |
| pub async fn greet(_ctx: ActivityContext, name: String) -> Result<String, ActivityError> { | |
| Ok(format!("Hello, {}!", name)) | |
| } | |
| #[activity] | |
| pub async fn send_notification(_ctx: ActivityContext, message: String) -> Result<(), ActivityError> { | |
| println!("Sending notification: {}", message); | |
| Ok(()) | |
| } | |
| } |
|
|
||
| **How to define Activity parameters using the Temporal Rust SDK.** | ||
|
|
||
| There is no explicit limit to the total number of parameters that an [Activity Definition](/activity-definition) may support. However, there is a limit to the total size of the data that ends up encoded into a gRPC message Payload. |
There was a problem hiding this comment.
For Rust we actually have a hard cap of 6 parameters for activities.
|
|
||
| We recommend that you use a single struct as an argument that wraps all the application data passed to Activities. This way you can change what data is passed to the Activity without breaking the function signature. | ||
|
|
||
| Activity parameters must be serializable and deserializable using serde. Use `#[derive(Serialize, Deserialize)]` on your data types: |
There was a problem hiding this comment.
This isn't a hard requirement, but implementing the serde traits are the easiest way to ensure they work. If they have a protobuf message they can leverage ProstSerializable for encoding without implementing the serde traits.
I am actively working on improving the ergonomics of using protobuf instead of serde, so I don't have a good sample yet.
What does this PR do?
This adds the docs for the Rust SDK.
Notes to reviewers
┆Attachments: EDU-6184 feat(rust): rust sdk docs