Skip to content

Commit e0eb5fb

Browse files
Add changes for the e2e tests
1 parent 2aae73c commit e0eb5fb

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pin-project-lite = "0.2"
2323
rand = { version = "0.8.5", optional = true }
2424
regress = "0.10"
2525
restate-sdk-macros = { version = "0.3.0", path = "macros" }
26-
restate-sdk-shared-core = "0.1.0"
26+
restate-sdk-shared-core = { git = "https://github.com/restatedev/sdk-shared-core.git", branch = "issues/cancel-invocation-get-invocation-id" }
2727
serde = "1.0"
2828
serde_json = "1.0"
2929
thiserror = "1.0.63"

test-services/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ RUN cargo build -p test-services
77
RUN cp ./target/debug/test-services /bin/server
88

99
ENV RUST_LOG="debug,restate_shared_core=trace"
10+
ENV RUST_BACKTRACE=1
1011

1112
CMD ["/bin/server"]

test-services/src/proxy.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub(crate) trait Proxy {
4646
#[name = "call"]
4747
async fn call(req: Json<ProxyRequest>) -> HandlerResult<Json<Vec<u8>>>;
4848
#[name = "oneWayCall"]
49-
async fn one_way_call(req: Json<ProxyRequest>) -> HandlerResult<()>;
49+
async fn one_way_call(req: Json<ProxyRequest>) -> HandlerResult<String>;
5050
#[name = "manyCalls"]
5151
async fn many_calls(req: Json<Vec<ManyCallRequest>>) -> HandlerResult<()>;
5252
}
@@ -70,16 +70,16 @@ impl Proxy for ProxyImpl {
7070
&self,
7171
ctx: Context<'_>,
7272
Json(req): Json<ProxyRequest>,
73-
) -> HandlerResult<()> {
73+
) -> HandlerResult<String> {
7474
let request = ctx.request::<_, ()>(req.to_target(), req.message);
7575

76-
if let Some(delay_millis) = req.delay_millis {
77-
request.send_with_delay(Duration::from_millis(delay_millis));
76+
let invocation_id = if let Some(delay_millis) = req.delay_millis {
77+
request.send_with_delay(Duration::from_millis(delay_millis)).invocation_id().await?
7878
} else {
79-
request.send();
80-
}
79+
request.send().invocation_id().await?
80+
};
8181

82-
Ok(())
82+
Ok(invocation_id)
8383
}
8484

8585
async fn many_calls(

test-services/src/test_utils_service.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use futures::FutureExt;
55
use restate_sdk::prelude::*;
66
use serde::{Deserialize, Serialize};
77
use std::collections::HashMap;
8+
use std::convert::Infallible;
89
use std::sync::atomic::{AtomicU8, Ordering};
910
use std::sync::Arc;
1011
use std::time::Duration;
@@ -62,6 +63,8 @@ pub(crate) trait TestUtilsService {
6263
async fn count_executed_side_effects(increments: u32) -> HandlerResult<u32>;
6364
#[name = "getEnvVariable"]
6465
async fn get_env_variable(env: String) -> HandlerResult<String>;
66+
#[name = "cancelInvocation"]
67+
async fn cancel_invocation(invocation_id: String) -> Result<(), Infallible>;
6568
#[name = "interpretCommands"]
6669
async fn interpret_commands(req: Json<InterpretRequest>) -> HandlerResult<()>;
6770
}
@@ -155,6 +158,12 @@ impl TestUtilsService for TestUtilsServiceImpl {
155158
Ok(std::env::var(env).ok().unwrap_or_default())
156159
}
157160

161+
async fn cancel_invocation(&self, ctx: Context<'_>, invocation_id: String) -> Result<(), Infallible> {
162+
ctx.invocation_handle(invocation_id)
163+
.cancel();
164+
Ok(())
165+
}
166+
158167
async fn interpret_commands(
159168
&self,
160169
context: Context<'_>,

0 commit comments

Comments
 (0)