refactor suppression reason overall
This commit is contained in:
@@ -22,8 +22,8 @@ pub enum SuppressionReason {
|
|||||||
/// Suppressed by route limiters. Contains the index and result for each
|
/// Suppressed by route limiters. Contains the index and result for each
|
||||||
/// route whose filter matched but whose limiter blocked the message.
|
/// route whose filter matched but whose limiter blocked the message.
|
||||||
Routes(Vec<(usize, LimitResult)>),
|
Routes(Vec<(usize, LimitResult)>),
|
||||||
/// Suppressed by an overall limiter.
|
/// Suppressed by an overall limiter at the given index.
|
||||||
Overall(LimitResult),
|
OverallLimiter(usize),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for SuppressionReason {
|
impl fmt::Display for SuppressionReason {
|
||||||
@@ -40,8 +40,8 @@ impl fmt::Display for SuppressionReason {
|
|||||||
}
|
}
|
||||||
write!(f, "]")
|
write!(f, "]")
|
||||||
}
|
}
|
||||||
SuppressionReason::Overall(result) => {
|
SuppressionReason::OverallLimiter(idx) => {
|
||||||
write!(f, "overall:{result:?}")
|
write!(f, "overall[{idx}]")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -263,7 +263,7 @@ impl LogHandler {
|
|||||||
|
|
||||||
// At least one route passed, now check overall limits
|
// At least one route passed, now check overall limits
|
||||||
if let Err(i) = evaluate_limiter_sequence(&self.overall_limits, log_msg) {
|
if let Err(i) = evaluate_limiter_sequence(&self.overall_limits, log_msg) {
|
||||||
return Err(SuppressionReason::Overall(LimitResult::OverallLimiter(i)));
|
return Err(SuppressionReason::OverallLimiter(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
// All checks passed
|
// All checks passed
|
||||||
|
|||||||
@@ -16,8 +16,6 @@ pub enum LimitResult {
|
|||||||
Limiter(usize),
|
Limiter(usize),
|
||||||
/// The event was blocked by a global limiter at the given index.
|
/// The event was blocked by a global limiter at the given index.
|
||||||
GlobalLimiter(usize),
|
GlobalLimiter(usize),
|
||||||
/// The event was blocked by an overall limiter at the given index.
|
|
||||||
OverallLimiter(usize),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A set of limiters for a route, containing both per-origin and global limiters.
|
/// A set of limiters for a route, containing both per-origin and global limiters.
|
||||||
|
|||||||
Reference in New Issue
Block a user