Skip to content

Commit b0c7151

Browse files
committed
Bump restate-sdk-shared-core to 0.7.1 and update outdated dependencies
Bump restate-sdk-shared-core from 0.6.0 to 0.7.1 and update other outdated dependencies to their latest versions (aws_lambda_events 1.0, lambda_runtime 1.0, typify 0.6, jsonptr 0.7, regress 0.10). Adapt to breaking changes: - TerminalFailure now has a metadata field - PayloadOptions parameter added to multiple VM syscalls - TypeSpace::new() now takes a reference to settings - typify generates NonZero<u64> for protocol version fields - Base64Data is now #[non_exhaustive] - notify_error signature changed Closes #92
1 parent 9f57860 commit b0c7151

13 files changed

Lines changed: 89 additions & 61 deletions

File tree

Cargo.toml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,44 +25,44 @@ tracing-span-filter = ["dep:tracing-subscriber"]
2525
lambda = [ "dep:http-serde", "dep:lambda_runtime", "dep:aws_lambda_events"]
2626

2727
[dependencies]
28-
bytes = "1.10"
28+
bytes = "1.11"
2929
futures = "0.3"
30-
http = "1.3"
30+
http = "1.4"
3131
http-body = "1.0.1"
3232
http-body-util = { version = "0.1", optional = true }
33-
hyper = { version = "1.6", optional = true}
33+
hyper = { version = "1.8", optional = true}
3434
hyper-util = { version = "0.1", features = ["tokio", "server", "server-graceful", "http2"], optional = true }
3535
pin-project-lite = "0.2"
36-
rand = { version = "0.9", optional = true }
37-
regress = "=0.10.3"
36+
rand = { version = "0.10", optional = true }
37+
regress = "0.10"
3838
restate-sdk-macros = { version = "0.8", path = "macros" }
39-
restate-sdk-shared-core = { version = "=0.6.0", features = ["request_identity", "sha2_random_seed", "http"] }
40-
schemars = { version = "1.0.0", optional = true }
39+
restate-sdk-shared-core = { version = "=0.7.1", features = ["request_identity", "sha2_random_seed", "http"] }
40+
schemars = { version = "1.2", optional = true }
4141
serde = "1.0"
4242
serde_json = "1.0"
4343
thiserror = "2.0"
44-
tokio = { version = "1.44", default-features = false, features = ["sync"] }
44+
tokio = { version = "1.49", default-features = false, features = ["sync"] }
4545
tracing = "0.1"
4646
tracing-subscriber = { version = "0.3", features = ["registry"], optional = true }
47-
uuid = { version = "1.16.0", optional = true }
47+
uuid = { version = "1.20", optional = true }
4848
http-serde = { version = "2.1.1", optional = true }
49-
aws_lambda_events = { version = "0.16.1", optional = true }
50-
lambda_runtime = { version = "0.14.2", optional = true }
49+
aws_lambda_events = { version = "1.0", optional = true }
50+
lambda_runtime = { version = "1.0", optional = true }
5151

5252
[dev-dependencies]
5353
tokio = { version = "1", features = ["full"] }
5454
tracing-subscriber = { version = "0.3", features = ["env-filter", "registry"] }
5555
trybuild = "1.0"
56-
reqwest = { version = "0.12", features = ["json"] }
57-
rand = "0.9"
58-
schemars = "1.0.0-alpha.17"
56+
reqwest = { version = "0.13", features = ["json"] }
57+
rand = "0.10"
58+
schemars = "1.2"
5959

6060
[build-dependencies]
61-
jsonptr = "0.5.1"
61+
jsonptr = "0.7"
6262
prettyplease = "0.2"
6363
serde_json = { version = "1.0" }
6464
syn = "2.0"
65-
typify = { version = "0.1.0" }
65+
typify = { version = "0.6" }
6666

6767
[workspace]
6868
members = ["macros", "test-services", "testcontainers"]

build.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,8 @@ fn main() -> std::io::Result<()> {
4646
.add_root_schema(serde_json::from_value(parsed_content).unwrap())
4747
.unwrap();
4848

49-
let contents = format!(
50-
"{}\n{}",
51-
"use serde::{Deserialize, Serialize};",
52-
prettyplease::unparse(&syn::parse2::<syn::File>(type_space.to_stream()).unwrap())
53-
);
54-
55-
std::fs::write(out_dir.join("endpoint_manifest.rs"), contents)
49+
std::fs::write(
50+
out_dir.join("endpoint_manifest.rs"),
51+
prettyplease::unparse(&syn::parse2::<syn::File>(type_space.to_stream()).unwrap()),
52+
)
5653
}

examples/failures.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rand::RngCore;
1+
use rand::Rng;
22
use restate_sdk::prelude::*;
33

44
#[restate_sdk::service]

src/context/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -779,13 +779,13 @@ pub trait ContextSideEffects<'ctx>: private::SealedContext<'ctx> {
779779

780780
/// ### Generating random numbers
781781
///
782-
/// Return a [`rand::Rng`] instance inherently predictable, seeded with [`ContextSideEffects::random_seed`].
782+
/// Return a [`rand::RngExt`] instance inherently predictable, seeded with [`ContextSideEffects::random_seed`].
783783
///
784784
/// For example, you can use this to generate a random number:
785785
///
786786
/// ```rust,no_run
787787
/// # use restate_sdk::prelude::*;
788-
/// # use rand::Rng;
788+
/// # use rand::RngExt;
789789
/// async fn rand_generate(mut ctx: Context<'_>) {
790790
/// let x: u32 = ctx.rand().random();
791791
/// # }
@@ -815,7 +815,7 @@ pub trait ContextSideEffects<'ctx>: private::SealedContext<'ctx> {
815815
#[cfg(all(feature = "rand", feature = "uuid"))]
816816
fn rand_uuid(&mut self) -> uuid::Uuid {
817817
let rand = private::SealedContext::rand(self);
818-
uuid::Uuid::from_u64_pair(rand::RngCore::next_u64(rand), rand::RngCore::next_u64(rand))
818+
uuid::Uuid::from_u64_pair(rand::Rng::next_u64(rand), rand::Rng::next_u64(rand))
819819
}
820820
}
821821

src/discovery.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
mod generated {
44
#![allow(clippy::clone_on_copy)]
55
#![allow(clippy::to_string_trait_impl)]
6+
#![allow(clippy::derivable_impls)]
67

78
include!(concat!(env!("OUT_DIR"), "/endpoint_manifest.rs"));
89
}

src/endpoint/context.rs

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ use futures::{FutureExt, TryFutureExt};
1616
use pin_project_lite::pin_project;
1717
use restate_sdk_shared_core::{
1818
CoreVM, DoProgressResponse, Error as CoreError, Header, NonEmptyValue, NotificationHandle,
19-
RetryPolicy, RunExitResult, TakeOutputResult, Target, TerminalFailure, VM, Value,
19+
PayloadOptions, RetryPolicy, RunExitResult, TakeOutputResult, Target, TerminalFailure, VM,
20+
Value,
2021
};
2122
use std::borrow::Cow;
2223
use std::collections::HashMap;
@@ -59,7 +60,7 @@ impl ContextInternalInner {
5960
self.maybe_flip_span_replaying_field();
6061
self.vm.notify_error(
6162
CoreError::new(500u16, e.0.to_string())
62-
.with_stacktrace(Cow::Owned(format!("{:#}", e.0))),
63+
.with_stacktrace(Cow::<str>::Owned(format!("{:#}", e.0))),
6364
None,
6465
);
6566
self.handler_state.mark_error(e);
@@ -237,7 +238,7 @@ impl ContextInternal {
237238
};
238239
let _ = inner_lock
239240
.vm
240-
.sys_write_output(NonEmptyValue::Failure(err.into()));
241+
.sys_write_output(NonEmptyValue::Failure(err.into()), PayloadOptions::stable());
241242
let _ = inner_lock.vm.sys_end();
242243
// This causes the trap, plus logs the error
243244
inner_lock.handler_state.mark_error(error_inner.into());
@@ -256,7 +257,12 @@ impl ContextInternal {
256257
key: &str,
257258
) -> impl Future<Output = Result<Option<T>, TerminalError>> + Send {
258259
let mut inner_lock = must_lock!(self.inner);
259-
let handle = unwrap_or_trap!(inner_lock, inner_lock.vm.sys_state_get(key.to_owned()));
260+
let handle = unwrap_or_trap!(
261+
inner_lock,
262+
inner_lock
263+
.vm
264+
.sys_state_get(key.to_owned(), PayloadOptions::stable())
265+
);
260266
inner_lock.maybe_flip_span_replaying_field();
261267

262268
let poll_future = get_async_result(Arc::clone(&self.inner), handle).map(|res| match res {
@@ -301,7 +307,9 @@ impl ContextInternal {
301307
let mut inner_lock = must_lock!(self.inner);
302308
match t.serialize() {
303309
Ok(b) => {
304-
let _ = inner_lock.vm.sys_state_set(key.to_owned(), b);
310+
let _ = inner_lock
311+
.vm
312+
.sys_state_set(key.to_owned(), b, PayloadOptions::stable());
305313
inner_lock.maybe_flip_span_replaying_field();
306314
}
307315
Err(e) => {
@@ -391,7 +399,12 @@ impl ContextInternal {
391399
.collect();
392400
let call_result = Req::serialize(&req)
393401
.map_err(|e| Error::serialization("call", e))
394-
.and_then(|input| inner_lock.vm.sys_call(target, input).map_err(Into::into));
402+
.and_then(|input| {
403+
inner_lock
404+
.vm
405+
.sys_call(target, input, PayloadOptions::stable())
406+
.map_err(Into::into)
407+
});
395408

396409
let call_handle = match call_result {
397410
Ok(t) => t,
@@ -487,6 +500,7 @@ impl ContextInternal {
487500
.expect("Duration since unix epoch cannot fail")
488501
+ delay
489502
}),
503+
PayloadOptions::stable(),
490504
) {
491505
Ok(h) => h,
492506
Err(e) => {
@@ -579,9 +593,11 @@ impl ContextInternal {
579593
let mut inner_lock = must_lock!(self.inner);
580594
match t.serialize() {
581595
Ok(b) => {
582-
let _ = inner_lock
583-
.vm
584-
.sys_complete_awakeable(id.to_owned(), NonEmptyValue::Success(b));
596+
let _ = inner_lock.vm.sys_complete_awakeable(
597+
id.to_owned(),
598+
NonEmptyValue::Success(b),
599+
PayloadOptions::stable(),
600+
);
585601
}
586602
Err(e) => {
587603
inner_lock.fail(Error::serialization("resolve_awakeable", e));
@@ -590,9 +606,11 @@ impl ContextInternal {
590606
}
591607

592608
pub fn reject_awakeable(&self, id: &str, failure: TerminalError) {
593-
let _ = must_lock!(self.inner)
594-
.vm
595-
.sys_complete_awakeable(id.to_owned(), NonEmptyValue::Failure(failure.into()));
609+
let _ = must_lock!(self.inner).vm.sys_complete_awakeable(
610+
id.to_owned(),
611+
NonEmptyValue::Failure(failure.into()),
612+
PayloadOptions::stable(),
613+
);
596614
}
597615

598616
pub fn promise<T: Deserialize>(
@@ -657,9 +675,11 @@ impl ContextInternal {
657675
let mut inner_lock = must_lock!(self.inner);
658676
match t.serialize() {
659677
Ok(b) => {
660-
let _ = inner_lock
661-
.vm
662-
.sys_complete_promise(name.to_owned(), NonEmptyValue::Success(b));
678+
let _ = inner_lock.vm.sys_complete_promise(
679+
name.to_owned(),
680+
NonEmptyValue::Success(b),
681+
PayloadOptions::stable(),
682+
);
663683
}
664684
Err(e) => {
665685
inner_lock.fail(
@@ -674,9 +694,11 @@ impl ContextInternal {
674694
}
675695

676696
pub fn reject_promise(&self, id: &str, failure: TerminalError) {
677-
let _ = must_lock!(self.inner)
678-
.vm
679-
.sys_complete_promise(id.to_owned(), NonEmptyValue::Failure(failure.into()));
697+
let _ = must_lock!(self.inner).vm.sys_complete_promise(
698+
id.to_owned(),
699+
NonEmptyValue::Failure(failure.into()),
700+
PayloadOptions::stable(),
701+
);
680702
}
681703

682704
pub fn run<'a, Run, Fut, Out>(
@@ -719,7 +741,9 @@ impl ContextInternal {
719741
},
720742
};
721743

722-
let _ = inner_lock.vm.sys_write_output(res_to_write);
744+
let _ = inner_lock
745+
.vm
746+
.sys_write_output(res_to_write, PayloadOptions::stable());
723747
inner_lock.maybe_flip_span_replaying_field();
724748
}
725749

@@ -886,6 +910,7 @@ where
886910
Ok(Err(TerminalError::from(TerminalFailure {
887911
code: 409,
888912
message: "cancelled".to_string(),
913+
metadata: vec![],
889914
})))
890915
}
891916
.boxed(),

src/endpoint/futures/async_result_poll.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ impl Future for VmAsyncResultPollFuture {
121121
return Poll::Ready(Ok(Value::Failure(TerminalFailure {
122122
code: 409,
123123
message: "cancelled".to_string(),
124+
metadata: vec![],
124125
})));
125126
}
126127
Err(e) => {

src/endpoint/futures/select_poll.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ impl Future for VmSelectAsyncResultPollFuture {
124124
return Poll::Ready(Ok(Err(TerminalFailure {
125125
code: 409,
126126
message: "cancelled".to_string(),
127+
metadata: vec![],
127128
}
128129
.into())));
129130
}

src/endpoint/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,8 @@ impl Endpoint {
333333
Bytes::from(
334334
serde_json::to_string(&crate::discovery::Endpoint {
335335
lambda_compression: None,
336-
max_protocol_version: 5,
337-
min_protocol_version: 5,
336+
max_protocol_version: std::num::NonZero::new(5).unwrap(),
337+
min_protocol_version: std::num::NonZero::new(5).unwrap(),
338338
protocol_mode: Some(match protocol_mode {
339339
ProtocolMode::RequestResponse => {
340340
crate::discovery::ProtocolMode::RequestResponse

src/errors.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ impl From<TerminalError> for TerminalFailure {
155155
Self {
156156
code: value.0.code,
157157
message: value.0.message,
158+
metadata: vec![],
158159
}
159160
}
160161
}

0 commit comments

Comments
 (0)