|
1 | | -use std::fmt; |
2 | 1 | use pyo3::create_exception; |
3 | 2 | use pyo3::prelude::*; |
4 | 3 | use pyo3::types::{PyBytes, PyNone, PyString}; |
| 4 | +use restate_sdk_shared_core::fmt::{set_error_formatter, ErrorFormatter}; |
5 | 5 | use restate_sdk_shared_core::{ |
6 | 6 | CallHandle, CoreVM, DoProgressResponse, Error, Header, IdentityVerifier, Input, NonEmptyValue, |
7 | 7 | NotificationHandle, ResponseHead, RetryPolicy, RunExitResult, TakeOutputResult, Target, |
8 | 8 | TerminalFailure, VMOptions, Value, CANCEL_NOTIFICATION_HANDLE, VM, |
9 | 9 | }; |
| 10 | +use std::fmt; |
10 | 11 | use std::time::{Duration, SystemTime}; |
11 | | -use restate_sdk_shared_core::fmt::{set_error_formatter, ErrorFormatter}; |
12 | 12 |
|
13 | 13 | // Current crate version |
14 | 14 | const CURRENT_VERSION: &str = env!("CARGO_PKG_VERSION"); |
@@ -144,18 +144,26 @@ impl PyExponentialRetryConfig { |
144 | 144 |
|
145 | 145 | impl From<PyExponentialRetryConfig> for RetryPolicy { |
146 | 146 | 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 | + { |
148 | 153 | // If any of the values are set, then let's create the exponential retry policy |
149 | 154 | RetryPolicy::Exponential { |
150 | 155 | initial_interval: Duration::from_millis(value.initial_interval.unwrap_or(50)), |
151 | 156 | max_attempts: value.max_attempts, |
152 | 157 | max_duration: value.max_duration.map(Duration::from_millis), |
153 | 158 | 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))), |
155 | 163 | } |
156 | 164 | } else { |
157 | 165 | // Let's use retry policy infinite here, which will give back control to the invocation retry policy |
158 | | - RetryPolicy::Infinite |
| 166 | + RetryPolicy::Infinite |
159 | 167 | } |
160 | 168 | } |
161 | 169 | } |
|
0 commit comments