Skip to content

Commit

Permalink
review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
conorbros committed Sep 4, 2023
1 parent e3e2597 commit b427243
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
3 changes: 3 additions & 0 deletions docs/src/transforms.md
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,9 @@ The response from the down-chain transform is returned back up-chain but various
# If the responses returned by the sub chain do not equal the responses returned by down-chain then return an error.
# behavior: FailOnMismatch
#
# If the responses returned by the sub chain do not equal the responses returned by down-chain then log the mismatch at the warning level.
# behavior: LogOnMismatch
#
# If the responses returned by the sub chain do not equal the responses returned by down-chain,
# then the original message is also sent down the SubchainOnMismatch sub chain.
# This is useful for logging failed messages.
Expand Down
2 changes: 1 addition & 1 deletion shotover-proxy/tests/test-configs/tee/log.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ sources:
chain_config:
redis_chain:
- Tee:
behavior: LogMismatch
behavior: LogWarningOnMismatch
buffer_size: 10000
chain:
- QueryTypeFilter:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ sources:
chain_config:
redis_chain:
- Tee:
behavior: LogMismatch
behavior: LogWarningOnMismatch
buffer_size: 10000
chain:
- QueryTypeFilter:
Expand Down
16 changes: 10 additions & 6 deletions shotover/src/transforms/tee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub struct TeeBuilder {

pub enum ConsistencyBehaviorBuilder {
Ignore,
LogMismatch,
LogWarningOnMismatch,
FailOnMismatch,
SubchainOnMismatch(TransformChainBuilder),
}
Expand Down Expand Up @@ -48,7 +48,9 @@ impl TransformBuilder for TeeBuilder {
tx: self.tx.build_buffered(self.buffer_size),
behavior: match &self.behavior {
ConsistencyBehaviorBuilder::Ignore => ConsistencyBehavior::Ignore,
ConsistencyBehaviorBuilder::LogMismatch => ConsistencyBehavior::LogMismatch,
ConsistencyBehaviorBuilder::LogWarningOnMismatch => {
ConsistencyBehavior::LogWarningOnMismatch
}
ConsistencyBehaviorBuilder::FailOnMismatch => ConsistencyBehavior::FailOnMismatch,
ConsistencyBehaviorBuilder::SubchainOnMismatch(chain) => {
ConsistencyBehavior::SubchainOnMismatch(chain.build_buffered(self.buffer_size))
Expand Down Expand Up @@ -99,7 +101,7 @@ pub struct Tee {

pub enum ConsistencyBehavior {
Ignore,
LogMismatch,
LogWarningOnMismatch,
FailOnMismatch,
SubchainOnMismatch(BufferedChain),
}
Expand All @@ -117,7 +119,7 @@ pub struct TeeConfig {
#[serde(deny_unknown_fields)]
pub enum ConsistencyBehaviorConfig {
Ignore,
LogMismatch,
LogWarningOnMismatch,
FailOnMismatch,
SubchainOnMismatch(TransformChainConfig),
}
Expand All @@ -132,7 +134,9 @@ impl TransformConfig for TeeConfig {
Some(ConsistencyBehaviorConfig::FailOnMismatch) => {
ConsistencyBehaviorBuilder::FailOnMismatch
}
Some(ConsistencyBehaviorConfig::LogMismatch) => ConsistencyBehaviorBuilder::LogMismatch,
Some(ConsistencyBehaviorConfig::LogWarningOnMismatch) => {
ConsistencyBehaviorBuilder::LogWarningOnMismatch
}
Some(ConsistencyBehaviorConfig::SubchainOnMismatch(mismatch_chain)) => {
ConsistencyBehaviorBuilder::SubchainOnMismatch(
mismatch_chain
Expand Down Expand Up @@ -203,7 +207,7 @@ impl Transform for Tee {

Ok(chain_response)
}
ConsistencyBehavior::LogMismatch => {
ConsistencyBehavior::LogWarningOnMismatch => {
let (tee_result, chain_result) = tokio::join!(
self.tx
.process_request(requests_wrapper.clone(), self.timeout_micros),
Expand Down

0 comments on commit b427243

Please sign in to comment.