Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ doc = false
[dependencies]
pyo3 = { version = "0.24.1", features = ["extension-module"] }
tracing-subscriber = { version = "0.3", features = ["fmt", "env-filter"] }
restate-sdk-shared-core = { version = "0.3.0", features = ["request_identity", "sha2_random_seed"] }
restate-sdk-shared-core = { git = "https://github.com/restatedev/sdk-shared-core.git", rev = "96b78a6160880cc4b34c56750dd96652e11cd81c", features = ["request_identity", "sha2_random_seed"] }
41 changes: 23 additions & 18 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use pyo3::prelude::*;
use pyo3::types::{PyBytes, PyNone, PyString};
use restate_sdk_shared_core::{
CallHandle, CoreVM, DoProgressResponse, Error, Header, IdentityVerifier, Input, NonEmptyValue,
NotificationHandle, ResponseHead, RetryPolicy, RunExitResult, SuspendedOrVMError,
TakeOutputResult, Target, TerminalFailure, VMOptions, Value, CANCEL_NOTIFICATION_HANDLE, VM,
NotificationHandle, ResponseHead, RetryPolicy, RunExitResult, TakeOutputResult, Target,
TerminalFailure, VMOptions, Value, CANCEL_NOTIFICATION_HANDLE, VM,
};
use std::time::{Duration, SystemTime};

Expand Down Expand Up @@ -330,10 +330,10 @@ impl PyVM {
let py = self_.py();

match res {
Err(SuspendedOrVMError::VM(e)) => Err(e.into()),
Err(SuspendedOrVMError::Suspended(_)) => {
Err(e) if e.is_suspended_error() => {
Ok(PySuspended.into_py(py).into_bound(py).into_any())
}
Err(e) => Err(e.into()),
Ok(DoProgressResponse::AnyCompleted) => Ok(PyDoProgressAnyCompleted
.into_py(py)
.into_bound(py)
Expand All @@ -352,10 +352,9 @@ impl PyVM {
.into_py(py)
.into_bound(py)
.into_any()),
Ok(DoProgressResponse::WaitingPendingRun) => Ok(PyDoWaitForPendingRun
.into_py(py)
.into_bound(py)
.into_any()),
Ok(DoProgressResponse::WaitingPendingRun) => {
Ok(PyDoWaitForPendingRun.into_py(py).into_bound(py).into_any())
}
}
}

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

match res {
Err(SuspendedOrVMError::VM(e)) => Err(e.into()),
Err(SuspendedOrVMError::Suspended(_)) => {
Err(e) if e.is_suspended_error() => {
Ok(PySuspended.into_py(py).into_bound(py).into_any())
}
Err(e) => Err(e.into()),
Ok(None) => Ok(PyNone::get_bound(py).to_owned().into_any()),
Ok(Some(Value::Void)) => Ok(PyVoid.into_py(py).into_bound(py).into_any()),
Ok(Some(Value::Success(b))) => Ok(PyBytes::new_bound(py, &b).into_any()),
Expand Down Expand Up @@ -451,7 +450,11 @@ impl PyVM {
.expect("Duration since unix epoch cannot fail");
self_
.vm
.sys_sleep(String::default(), now + Duration::from_millis(millis), Some(now))
.sys_sleep(
String::default(),
now + Duration::from_millis(millis),
Some(now),
)
.map(Into::into)
.map_err(Into::into)
}
Expand Down Expand Up @@ -494,7 +497,7 @@ impl PyVM {
buffer: &Bound<'_, PyBytes>,
key: Option<String>,
delay: Option<u64>,
idempotency_key: Option<String>,
idempotency_key: Option<String>,
headers: Option<Vec<PyHeader>>,
) -> Result<PyNotificationHandle, PyVMError> {
self_
Expand Down Expand Up @@ -615,11 +618,11 @@ impl PyVM {
self_.vm.sys_run(name).map(Into::into).map_err(Into::into)
}

fn sys_cancel(
mut self_: PyRefMut<'_, Self>,
invocation_id: String,
) -> Result<(), PyVMError> {
self_.vm.sys_cancel_invocation(invocation_id).map_err(Into::into)
fn sys_cancel(mut self_: PyRefMut<'_, Self>, invocation_id: String) -> Result<(), PyVMError> {
self_
.vm
.sys_cancel_invocation(invocation_id)
.map_err(Into::into)
}

fn propose_run_completion_success(
Expand Down Expand Up @@ -699,7 +702,9 @@ impl PyVM {
) -> Result<PyNotificationHandle, PyVMError> {
self_
.vm
.sys_attach_invocation(restate_sdk_shared_core::AttachInvocationTarget::InvocationId(invocation_id))
.sys_attach_invocation(
restate_sdk_shared_core::AttachInvocationTarget::InvocationId(invocation_id),
)
.map(Into::into)
.map_err(Into::into)
}
Expand Down