pub struct CallPolicy {
pub deadline: Option<Duration>,
pub max_attempts: u32,
pub base_backoff: Duration,
pub max_retry_after: Duration,
pub idempotent: bool,
}Expand description
Per-call deadline and retry policy.
Retries are bounded and only ever applied where the caller has said the
operation is safe to repeat — see CallPolicy::idempotent.
Fields§
§deadline: Option<Duration>§max_attempts: u32§base_backoff: Duration§max_retry_after: DurationThe longest broker-requested delay (ErrorDetail.retry_after_ms) the
client waits for automatically; a longer one is returned to the caller
at once (the UdbError keeps retry_after). Defaults to 10 s.
idempotent: boolWhether the operation may be safely repeated. Defaults to false: a
blanket retry on a mutation is how one payment becomes two.
Implementations§
Source§impl CallPolicy
impl CallPolicy
Sourcepub fn idempotent() -> Self
pub fn idempotent() -> Self
A read: safe to repeat.
Sourcepub fn from_contract(path: &str) -> Self
pub fn from_contract(path: &str) -> Self
The policy the CONTRACT implies for one RPC path.
This replaced a hand-written per-method judgement, which was wrong in both
directions: it refused to retry Upsert, Update and Delete even
though the broker declares them replayable, costing availability on a
transient failure the broker was happy to see again.
Deciding from the descriptor instead of a method name is the point of the
operation_kind annotation. An unknown path yields the conservative
default (no retries).
pub fn with_deadline(self, deadline: Duration) -> Self
pub fn with_max_attempts(self, attempts: u32) -> Self
Sourcepub fn with_max_retry_after(self, cap: Duration) -> Self
pub fn with_max_retry_after(self, cap: Duration) -> Self
The longest broker-requested retry delay this policy waits for; a longer one is returned to the caller at once.
Trait Implementations§
Auto Trait Implementations§
impl Forget for CallPolicy
impl Freeze for CallPolicy
impl Move for CallPolicy
impl RefUnwindSafe for CallPolicy
impl Send for CallPolicy
impl Sync for CallPolicy
impl Unpin for CallPolicy
impl UnsafeUnpin for CallPolicy
impl UnwindSafe for CallPolicy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request