Skip to content

Commit

Permalink
Fix clippy and running of different parts
Browse files Browse the repository at this point in the history
  • Loading branch information
gvdongen committed Dec 4, 2024
1 parent 1f8d7a6 commit 3ffba30
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 21 deletions.
6 changes: 3 additions & 3 deletions tutorials/tour-of-restate-rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
3 changes: 2 additions & 1 deletion tutorials/tour-of-restate-rust/src/part2/cart_object.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::collections::HashSet;
use crate::checkout_service::{CheckoutRequest, CheckoutServiceClient};
use crate::ticket_object::TicketObjectClient;
use restate_sdk::prelude::*;
Expand Down Expand Up @@ -43,7 +44,7 @@ impl CartObject for CartObjectImpl {
.service_client::<CheckoutServiceClient>()
.handle(Json(CheckoutRequest {
user_id: ctx.key().parse()?,
tickets: vec!(String::from("seat2B")),
tickets: HashSet::from([String::from("seat2B")]),
}))
.call()
.await?;
Expand Down
6 changes: 2 additions & 4 deletions tutorials/tour-of-restate-rust/src/part2/checkout_service.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand All @@ -21,8 +19,8 @@ pub struct CheckoutServiceImpl;
impl CheckoutService for CheckoutServiceImpl {
async fn handle(
&self,
mut ctx: Context<'_>,
Json(CheckoutRequest { user_id, tickets }): Json<CheckoutRequest>,
_ctx: Context<'_>,
Json(CheckoutRequest { user_id: _, tickets: _ }): Json<CheckoutRequest>,
) -> Result<bool, HandlerError> {
Ok(true)
}
Expand Down
7 changes: 3 additions & 4 deletions tutorials/tour-of-restate-rust/src/part2/ticket_object.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::auxiliary::ticket_status::TicketStatus;
use restate_sdk::prelude::*;

#[restate_sdk::object]
Expand All @@ -12,15 +11,15 @@ pub(crate) trait TicketObject {
pub struct TicketObjectImpl;

impl TicketObject for TicketObjectImpl {
async fn reserve(&self, ctx: ObjectContext<'_>) -> Result<bool, HandlerError> {
async fn reserve(&self, _ctx: ObjectContext<'_>) -> Result<bool, HandlerError> {
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(())
}
}
3 changes: 2 additions & 1 deletion tutorials/tour-of-restate-rust/src/part3/cart_object.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::collections::HashSet;
use crate::checkout_service::{CheckoutRequest, CheckoutServiceClient};
use crate::ticket_object::TicketObjectClient;
use restate_sdk::prelude::*;
Expand Down Expand Up @@ -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::<CartObjectClient>(ctx.key())
Expand Down
6 changes: 2 additions & 4 deletions tutorials/tour-of-restate-rust/src/part3/checkout_service.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand All @@ -21,8 +19,8 @@ pub struct CheckoutServiceImpl;
impl CheckoutService for CheckoutServiceImpl {
async fn handle(
&self,
mut ctx: Context<'_>,
Json(CheckoutRequest { user_id, tickets }): Json<CheckoutRequest>,
_ctx: Context<'_>,
Json(CheckoutRequest { user_id: _, tickets: _ }): Json<CheckoutRequest>,
) -> Result<bool, HandlerError> {
Ok(true)
}
Expand Down
1 change: 0 additions & 1 deletion tutorials/tour-of-restate-rust/src/part4/cart_object.rs
Original file line number Diff line number Diff line change
@@ -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::*;
Expand Down
6 changes: 3 additions & 3 deletions tutorials/tour-of-restate-rust/src/part4/checkout_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3ffba30

Please sign in to comment.