Skip to content

Commit

Permalink
Only show filter warning once (#761)
Browse files Browse the repository at this point in the history
  • Loading branch information
conorbros authored Aug 31, 2022
1 parent 89e874d commit eb2d8b3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions shotover-proxy/src/transforms/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ use crate::transforms::{Transform, Transforms, Wrapper};
use anyhow::Result;
use async_trait::async_trait;
use serde::Deserialize;
use std::sync::atomic::{AtomicBool, Ordering};

static SHOWN_ERROR: AtomicBool = AtomicBool::new(false);

#[derive(Debug, Clone)]
pub struct QueryTypeFilter {
Expand Down Expand Up @@ -44,16 +47,21 @@ impl Transform for QueryTypeFilter {
message_wrapper.messages.remove(*i);
}

let mut shown_error = SHOWN_ERROR.load(Ordering::Relaxed);

message_wrapper
.call_next_transform()
.await
.map(|mut messages| {

for (i, message) in removed_indexes.into_iter() {
if i <= messages.len() {
messages.insert(i, message);
}
else {
tracing::error!("The current filter transform implementation does not obey the current transform invariants. see https://github.com/shotover/shotover-proxy/issues/499")
else if !shown_error{
tracing::error!("The current filter transform implementation does not obey the current transform invariants. see https://github.com/shotover/shotover-proxy/issues/499");
shown_error = true;
SHOWN_ERROR.store(true , Ordering::Relaxed);
}
}
messages
Expand Down

0 comments on commit eb2d8b3

Please sign in to comment.