diff --git a/tutorials/tour-of-restate-rust/Cargo.toml b/tutorials/tour-of-restate-rust/Cargo.toml index dbb4c433..e4869bf6 100644 --- a/tutorials/tour-of-restate-rust/Cargo.toml +++ b/tutorials/tour-of-restate-rust/Cargo.toml @@ -20,12 +20,12 @@ path = "src/part1/main.rs" [[bin]] name = "part2" -path = "src/part1/main.rs" +path = "src/part2/main.rs" [[bin]] name = "part3" -path = "src/part1/main.rs" +path = "src/part3/main.rs" [[bin]] name = "part4" -path = "src/part1/main.rs" +path = "src/part4/main.rs" diff --git a/tutorials/tour-of-restate-rust/src/part2/cart_object.rs b/tutorials/tour-of-restate-rust/src/part2/cart_object.rs index 5658999f..3e790273 100644 --- a/tutorials/tour-of-restate-rust/src/part2/cart_object.rs +++ b/tutorials/tour-of-restate-rust/src/part2/cart_object.rs @@ -1,3 +1,4 @@ +use std::collections::HashSet; use crate::checkout_service::{CheckoutRequest, CheckoutServiceClient}; use crate::ticket_object::TicketObjectClient; use restate_sdk::prelude::*; @@ -43,7 +44,7 @@ impl CartObject for CartObjectImpl { .service_client::() .handle(Json(CheckoutRequest { user_id: ctx.key().parse()?, - tickets: vec!(String::from("seat2B")), + tickets: HashSet::from([String::from("seat2B")]), })) .call() .await?; diff --git a/tutorials/tour-of-restate-rust/src/part2/checkout_service.rs b/tutorials/tour-of-restate-rust/src/part2/checkout_service.rs index 4a80218e..08b5ee30 100644 --- a/tutorials/tour-of-restate-rust/src/part2/checkout_service.rs +++ b/tutorials/tour-of-restate-rust/src/part2/checkout_service.rs @@ -1,6 +1,4 @@ use std::collections::HashSet; -use crate::auxiliary::email_client::EmailClient; -use crate::auxiliary::payment_client::PaymentClient; use restate_sdk::prelude::*; use serde::{Deserialize, Serialize}; @@ -21,8 +19,8 @@ pub struct CheckoutServiceImpl; impl CheckoutService for CheckoutServiceImpl { async fn handle( &self, - mut ctx: Context<'_>, - Json(CheckoutRequest { user_id, tickets }): Json, + _ctx: Context<'_>, + Json(CheckoutRequest { user_id: _, tickets: _ }): Json, ) -> Result { Ok(true) } diff --git a/tutorials/tour-of-restate-rust/src/part2/ticket_object.rs b/tutorials/tour-of-restate-rust/src/part2/ticket_object.rs index ffed55ba..71a72fc9 100644 --- a/tutorials/tour-of-restate-rust/src/part2/ticket_object.rs +++ b/tutorials/tour-of-restate-rust/src/part2/ticket_object.rs @@ -1,4 +1,3 @@ -use crate::auxiliary::ticket_status::TicketStatus; use restate_sdk::prelude::*; #[restate_sdk::object] @@ -12,15 +11,15 @@ pub(crate) trait TicketObject { pub struct TicketObjectImpl; impl TicketObject for TicketObjectImpl { - async fn reserve(&self, ctx: ObjectContext<'_>) -> Result { + async fn reserve(&self, _ctx: ObjectContext<'_>) -> Result { Ok(true) } - async fn unreserve(&self, ctx: ObjectContext<'_>) -> Result<(), HandlerError> { + async fn unreserve(&self, _ctx: ObjectContext<'_>) -> Result<(), HandlerError> { Ok(()) } - async fn mark_as_sold(&self, ctx: ObjectContext<'_>) -> Result<(), HandlerError> { + async fn mark_as_sold(&self, _ctx: ObjectContext<'_>) -> Result<(), HandlerError> { Ok(()) } } diff --git a/tutorials/tour-of-restate-rust/src/part3/cart_object.rs b/tutorials/tour-of-restate-rust/src/part3/cart_object.rs index 8d3b16bf..b49c5f72 100644 --- a/tutorials/tour-of-restate-rust/src/part3/cart_object.rs +++ b/tutorials/tour-of-restate-rust/src/part3/cart_object.rs @@ -1,3 +1,4 @@ +use std::collections::HashSet; use crate::checkout_service::{CheckoutRequest, CheckoutServiceClient}; use crate::ticket_object::TicketObjectClient; use restate_sdk::prelude::*; @@ -34,7 +35,7 @@ impl CartObject for CartObjectImpl { .await? .unwrap_or_default() .into_inner(); - tickets.push(ticket_id.clone()); + tickets.insert(ticket_id.clone()); ctx.set("tickets", Json(tickets)); ctx.object_client::(ctx.key()) diff --git a/tutorials/tour-of-restate-rust/src/part3/checkout_service.rs b/tutorials/tour-of-restate-rust/src/part3/checkout_service.rs index 4a80218e..08b5ee30 100644 --- a/tutorials/tour-of-restate-rust/src/part3/checkout_service.rs +++ b/tutorials/tour-of-restate-rust/src/part3/checkout_service.rs @@ -1,6 +1,4 @@ use std::collections::HashSet; -use crate::auxiliary::email_client::EmailClient; -use crate::auxiliary::payment_client::PaymentClient; use restate_sdk::prelude::*; use serde::{Deserialize, Serialize}; @@ -21,8 +19,8 @@ pub struct CheckoutServiceImpl; impl CheckoutService for CheckoutServiceImpl { async fn handle( &self, - mut ctx: Context<'_>, - Json(CheckoutRequest { user_id, tickets }): Json, + _ctx: Context<'_>, + Json(CheckoutRequest { user_id: _, tickets: _ }): Json, ) -> Result { Ok(true) } diff --git a/tutorials/tour-of-restate-rust/src/part4/cart_object.rs b/tutorials/tour-of-restate-rust/src/part4/cart_object.rs index f4a3b5e5..825006e0 100644 --- a/tutorials/tour-of-restate-rust/src/part4/cart_object.rs +++ b/tutorials/tour-of-restate-rust/src/part4/cart_object.rs @@ -1,5 +1,4 @@ use std::collections::HashSet; -use std::hash::Hash; use crate::checkout_service::{CheckoutRequest, CheckoutServiceClient}; use crate::ticket_object::TicketObjectClient; use restate_sdk::prelude::*; diff --git a/tutorials/tour-of-restate-rust/src/part4/checkout_service.rs b/tutorials/tour-of-restate-rust/src/part4/checkout_service.rs index 473ec9fb..83efbe2a 100644 --- a/tutorials/tour-of-restate-rust/src/part4/checkout_service.rs +++ b/tutorials/tour-of-restate-rust/src/part4/checkout_service.rs @@ -31,14 +31,14 @@ impl CheckoutService for CheckoutServiceImpl { let pay_client = PaymentClient::new(); let success = ctx - .run(|| PaymentClient.call(&idempotency_key, total_price)) + .run(|| pay_client.call(&idempotency_key, total_price)) .await?; if success { - ctx.run(|| EmailClient.notify_user_of_payment_success(&user_id)) + ctx.run(|| EmailClient::notify_user_of_payment_success(&user_id)) .await?; } else { - ctx.run(|| EmailClient.notify_user_of_payment_failure(&user_id)) + ctx.run(|| EmailClient::notify_user_of_payment_failure(&user_id)) .await?; } Ok(success)