pub struct DomainState {
pub host: String,
pub last_outcome: Option<Outcome>,
pub last_proxy: Option<String>,
pub successes: u32,
pub failures: u32,
pub cooldown_until: Option<u64>,
pub updated_at: u64,
}Expand description
Accumulated knowledge about a single host.
Fields§
§host: StringThe host this state describes (e.g. example.com).
last_outcome: Option<Outcome>The most recently recorded outcome, if any.
last_proxy: Option<String>The egress proxy URL used on the most recent recorded attempt.
successes: u32Count of successful attempts.
failures: u32Count of failed attempts (challenged/blocked/rate-limited).
cooldown_until: Option<u64>Unix timestamp (secs) before which the host should not be hit again.
updated_at: u64Unix timestamp (secs) of the last update.
Implementations§
Source§impl DomainState
impl DomainState
Sourcepub fn record(
&self,
outcome: Outcome,
proxy: Option<String>,
now: u64,
rate_limit_cooldown: Duration,
) -> Self
pub fn record( &self, outcome: Outcome, proxy: Option<String>, now: u64, rate_limit_cooldown: Duration, ) -> Self
Returns a new state reflecting outcome recorded at now (Unix secs).
proxy is the egress in play (kept if None). Counting:
Outcome::SuccessandOutcome::Challengedincrementsuccesses— in both cases the page was ultimately obtained (a challenge that cleared is a success, not a failure).Outcome::BlockedandOutcome::RateLimitedincrementfailures.
cooldown_until models the rate-limit back-off window: it is set only by
Outcome::RateLimited and cleared by every other outcome, so it always
reflects the most recent outcome. The receiver is left untouched
(immutable update).
Sourcepub fn in_cooldown(&self, now: u64) -> bool
pub fn in_cooldown(&self, now: u64) -> bool
Whether the host is still within its cooldown window at now.
Sourcepub fn cooldown_remaining(&self, now: u64) -> Option<Duration>
pub fn cooldown_remaining(&self, now: u64) -> Option<Duration>
Remaining cooldown at now, if any.
Trait Implementations§
Source§impl Clone for DomainState
impl Clone for DomainState
Source§fn clone(&self) -> DomainState
fn clone(&self) -> DomainState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DomainState
impl Debug for DomainState
Source§impl<'de> Deserialize<'de> for DomainState
impl<'de> Deserialize<'de> for DomainState
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for DomainState
Source§impl PartialEq for DomainState
impl PartialEq for DomainState
Source§fn eq(&self, other: &DomainState) -> bool
fn eq(&self, other: &DomainState) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for DomainState
impl Serialize for DomainState
impl StructuralPartialEq for DomainState
Auto Trait Implementations§
impl Freeze for DomainState
impl RefUnwindSafe for DomainState
impl Send for DomainState
impl Sync for DomainState
impl Unpin for DomainState
impl UnsafeUnpin for DomainState
impl UnwindSafe for DomainState
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more