Skip to content

Commit 7ce1179

Browse files
Use new shared core (#106)
1 parent 576d838 commit 7ce1179

File tree

3 files changed

+25
-21
lines changed

3 files changed

+25
-21
lines changed

Cargo.lock

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ doc = false
1414
[dependencies]
1515
pyo3 = { version = "0.24.1", features = ["extension-module"] }
1616
tracing-subscriber = { version = "0.3", features = ["fmt", "env-filter"] }
17-
restate-sdk-shared-core = { version = "0.3.0", features = ["request_identity", "sha2_random_seed"] }
17+
restate-sdk-shared-core = { git = "https://github.com/restatedev/sdk-shared-core.git", rev = "96b78a6160880cc4b34c56750dd96652e11cd81c", features = ["request_identity", "sha2_random_seed"] }

src/lib.rs

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use pyo3::prelude::*;
33
use pyo3::types::{PyBytes, PyNone, PyString};
44
use restate_sdk_shared_core::{
55
CallHandle, CoreVM, DoProgressResponse, Error, Header, IdentityVerifier, Input, NonEmptyValue,
6-
NotificationHandle, ResponseHead, RetryPolicy, RunExitResult, SuspendedOrVMError,
7-
TakeOutputResult, Target, TerminalFailure, VMOptions, Value, CANCEL_NOTIFICATION_HANDLE, VM,
6+
NotificationHandle, ResponseHead, RetryPolicy, RunExitResult, TakeOutputResult, Target,
7+
TerminalFailure, VMOptions, Value, CANCEL_NOTIFICATION_HANDLE, VM,
88
};
99
use std::time::{Duration, SystemTime};
1010

@@ -330,10 +330,10 @@ impl PyVM {
330330
let py = self_.py();
331331

332332
match res {
333-
Err(SuspendedOrVMError::VM(e)) => Err(e.into()),
334-
Err(SuspendedOrVMError::Suspended(_)) => {
333+
Err(e) if e.is_suspended_error() => {
335334
Ok(PySuspended.into_py(py).into_bound(py).into_any())
336335
}
336+
Err(e) => Err(e.into()),
337337
Ok(DoProgressResponse::AnyCompleted) => Ok(PyDoProgressAnyCompleted
338338
.into_py(py)
339339
.into_bound(py)
@@ -352,10 +352,9 @@ impl PyVM {
352352
.into_py(py)
353353
.into_bound(py)
354354
.into_any()),
355-
Ok(DoProgressResponse::WaitingPendingRun) => Ok(PyDoWaitForPendingRun
356-
.into_py(py)
357-
.into_bound(py)
358-
.into_any()),
355+
Ok(DoProgressResponse::WaitingPendingRun) => {
356+
Ok(PyDoWaitForPendingRun.into_py(py).into_bound(py).into_any())
357+
}
359358
}
360359
}
361360

@@ -377,10 +376,10 @@ impl PyVM {
377376
let py = self_.py();
378377

379378
match res {
380-
Err(SuspendedOrVMError::VM(e)) => Err(e.into()),
381-
Err(SuspendedOrVMError::Suspended(_)) => {
379+
Err(e) if e.is_suspended_error() => {
382380
Ok(PySuspended.into_py(py).into_bound(py).into_any())
383381
}
382+
Err(e) => Err(e.into()),
384383
Ok(None) => Ok(PyNone::get_bound(py).to_owned().into_any()),
385384
Ok(Some(Value::Void)) => Ok(PyVoid.into_py(py).into_bound(py).into_any()),
386385
Ok(Some(Value::Success(b))) => Ok(PyBytes::new_bound(py, &b).into_any()),
@@ -451,7 +450,11 @@ impl PyVM {
451450
.expect("Duration since unix epoch cannot fail");
452451
self_
453452
.vm
454-
.sys_sleep(String::default(), now + Duration::from_millis(millis), Some(now))
453+
.sys_sleep(
454+
String::default(),
455+
now + Duration::from_millis(millis),
456+
Some(now),
457+
)
455458
.map(Into::into)
456459
.map_err(Into::into)
457460
}
@@ -494,7 +497,7 @@ impl PyVM {
494497
buffer: &Bound<'_, PyBytes>,
495498
key: Option<String>,
496499
delay: Option<u64>,
497-
idempotency_key: Option<String>,
500+
idempotency_key: Option<String>,
498501
headers: Option<Vec<PyHeader>>,
499502
) -> Result<PyNotificationHandle, PyVMError> {
500503
self_
@@ -615,11 +618,11 @@ impl PyVM {
615618
self_.vm.sys_run(name).map(Into::into).map_err(Into::into)
616619
}
617620

618-
fn sys_cancel(
619-
mut self_: PyRefMut<'_, Self>,
620-
invocation_id: String,
621-
) -> Result<(), PyVMError> {
622-
self_.vm.sys_cancel_invocation(invocation_id).map_err(Into::into)
621+
fn sys_cancel(mut self_: PyRefMut<'_, Self>, invocation_id: String) -> Result<(), PyVMError> {
622+
self_
623+
.vm
624+
.sys_cancel_invocation(invocation_id)
625+
.map_err(Into::into)
623626
}
624627

625628
fn propose_run_completion_success(
@@ -699,7 +702,9 @@ impl PyVM {
699702
) -> Result<PyNotificationHandle, PyVMError> {
700703
self_
701704
.vm
702-
.sys_attach_invocation(restate_sdk_shared_core::AttachInvocationTarget::InvocationId(invocation_id))
705+
.sys_attach_invocation(
706+
restate_sdk_shared_core::AttachInvocationTarget::InvocationId(invocation_id),
707+
)
703708
.map(Into::into)
704709
.map_err(Into::into)
705710
}

0 commit comments

Comments
 (0)