Skip to content

Commit 17cd6c8

Browse files
Format
1 parent 5816794 commit 17cd6c8

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/lib.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
use std::fmt;
21
use pyo3::create_exception;
32
use pyo3::prelude::*;
43
use pyo3::types::{PyBytes, PyNone, PyString};
4+
use restate_sdk_shared_core::fmt::{set_error_formatter, ErrorFormatter};
55
use restate_sdk_shared_core::{
66
CallHandle, CoreVM, DoProgressResponse, Error, Header, IdentityVerifier, Input, NonEmptyValue,
77
NotificationHandle, ResponseHead, RetryPolicy, RunExitResult, TakeOutputResult, Target,
88
TerminalFailure, VMOptions, Value, CANCEL_NOTIFICATION_HANDLE, VM,
99
};
10+
use std::fmt;
1011
use std::time::{Duration, SystemTime};
11-
use restate_sdk_shared_core::fmt::{set_error_formatter, ErrorFormatter};
1212

1313
// Current crate version
1414
const CURRENT_VERSION: &str = env!("CARGO_PKG_VERSION");
@@ -144,18 +144,26 @@ impl PyExponentialRetryConfig {
144144

145145
impl From<PyExponentialRetryConfig> for RetryPolicy {
146146
fn from(value: PyExponentialRetryConfig) -> Self {
147-
if value.initial_interval.is_some() || value.max_attempts.is_some() || value.max_duration.is_some() || value.max_interval.is_some() || value.factor.is_some() {
147+
if value.initial_interval.is_some()
148+
|| value.max_attempts.is_some()
149+
|| value.max_duration.is_some()
150+
|| value.max_interval.is_some()
151+
|| value.factor.is_some()
152+
{
148153
// If any of the values are set, then let's create the exponential retry policy
149154
RetryPolicy::Exponential {
150155
initial_interval: Duration::from_millis(value.initial_interval.unwrap_or(50)),
151156
max_attempts: value.max_attempts,
152157
max_duration: value.max_duration.map(Duration::from_millis),
153158
factor: value.factor.unwrap_or(2.0) as f32,
154-
max_interval: value.max_interval.map(Duration::from_millis).or_else(|| Some(Duration::from_secs(10))),
159+
max_interval: value
160+
.max_interval
161+
.map(Duration::from_millis)
162+
.or_else(|| Some(Duration::from_secs(10))),
155163
}
156164
} else {
157165
// Let's use retry policy infinite here, which will give back control to the invocation retry policy
158-
RetryPolicy::Infinite
166+
RetryPolicy::Infinite
159167
}
160168
}
161169
}

0 commit comments

Comments
 (0)