mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-24 18:14:14 +00:00
register redirect failure as global
This commit is contained in:
parent
e48d425672
commit
8091dd6ace
@ -81,7 +81,7 @@ impl Client {
|
||||
// * this condition just to make sure that client will never stuck by driver implementation issue
|
||||
if self.redirect.count() > redirect::LIMIT {
|
||||
self.status
|
||||
.replace(Status::failure_redirect_limit(redirect::LIMIT));
|
||||
.replace(Status::failure_redirect_limit(redirect::LIMIT, true));
|
||||
// @TODO return;
|
||||
}
|
||||
}
|
||||
|
@ -34,10 +34,10 @@ impl Status {
|
||||
}
|
||||
|
||||
/// Create new `Self::Failure` as `Failure::RedirectLimit`
|
||||
pub fn failure_redirect_limit(count: usize) -> Self {
|
||||
pub fn failure_redirect_limit(count: usize, is_global: bool) -> Self {
|
||||
Self::Failure {
|
||||
event: now(),
|
||||
failure: Failure::redirect_limit(count),
|
||||
failure: Failure::redirect_limit(count, is_global),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,26 +4,30 @@ use std::fmt::{Display, Formatter, Result};
|
||||
/// Local `Failure` status for `Client`
|
||||
pub enum Failure {
|
||||
/// Redirection count limit reached by protocol driver or global settings
|
||||
RedirectLimit { count: usize },
|
||||
RedirectLimit { count: usize, is_global: bool },
|
||||
}
|
||||
|
||||
impl Failure {
|
||||
// Constructors
|
||||
|
||||
/// Create new `Self::RedirectLimit`
|
||||
pub fn redirect_limit(count: usize) -> Self {
|
||||
Self::RedirectLimit { count }
|
||||
pub fn redirect_limit(count: usize, is_global: bool) -> Self {
|
||||
Self::RedirectLimit { count, is_global }
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for Failure {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result {
|
||||
match self {
|
||||
Self::RedirectLimit { count } => {
|
||||
write!(
|
||||
f,
|
||||
"Redirection limit ({count}) reached by protocol driver or global settings"
|
||||
)
|
||||
Self::RedirectLimit { count, is_global } => {
|
||||
if *is_global {
|
||||
write!(f, "Redirection limit ({count}) reached by global settings")
|
||||
} else {
|
||||
write!(
|
||||
f,
|
||||
"Redirection limit ({count}) reached by protocol restrictions"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user