Skip to content

Commit

Permalink
Rename TransformContextConfig::protocol -> up_chain_protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
rukai committed Aug 20, 2024
1 parent 70cf0be commit 723e852
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 18 deletions.
4 changes: 2 additions & 2 deletions shotover/benches/benches/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ fn criterion_benchmark(c: &mut Criterion) {
}
.get_builder(TransformContextConfig {
chain_name: "".into(),
protocol: MessageType::Redis,
up_chain_protocol: MessageType::Redis,
}),
)
.unwrap(),
Expand Down Expand Up @@ -239,7 +239,7 @@ fn criterion_benchmark(c: &mut Criterion) {
}
.get_builder(TransformContextConfig {
chain_name: "".into(),
protocol: MessageType::Redis,
up_chain_protocol: MessageType::Redis,
}),
)
.unwrap(),
Expand Down
4 changes: 2 additions & 2 deletions shotover/src/config/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl TransformChainConfig {
mut transform_context: TransformContextConfig,
) -> Result<TransformChainBuilder> {
let mut transforms: Vec<Box<dyn TransformBuilder>> = Vec::new();
let mut upchain_protocol = transform_context.protocol;
let mut upchain_protocol = transform_context.up_chain_protocol;
for (i, tc) in self.0.iter().enumerate() {
let name = tc.typetag_name();
match tc.up_chain_protocol() {
Expand All @@ -34,7 +34,7 @@ impl TransformChainConfig {
// anything is fine
}
}
transform_context.protocol = upchain_protocol;
transform_context.up_chain_protocol = upchain_protocol;
transforms.push(tc.get_builder(transform_context.clone()).await?);

upchain_protocol = match tc.down_chain_protocol() {
Expand Down
2 changes: 1 addition & 1 deletion shotover/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl<C: CodecBuilder + 'static> TcpCodecListener<C> {

let chain_usage_config = TransformContextConfig {
chain_name: source_name.clone(),
protocol: codec.protocol(),
up_chain_protocol: codec.protocol(),
};
let chain_builder = chain_config
.get_builder(chain_usage_config)
Expand Down
3 changes: 1 addition & 2 deletions shotover/src/transforms/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,8 @@ pub enum DownChainProtocol {
pub struct TransformContextConfig {
/// The name of the chain that this transform is configured in.
pub chain_name: String,
// TODO: rename to up_chain_protocol
/// The protocol that the transform will receive requests in.
pub protocol: MessageType,
pub up_chain_protocol: MessageType,
}

/// The [`Wrapper`] struct is passed into each transform and contains a list of mutable references to the
Expand Down
2 changes: 1 addition & 1 deletion shotover/src/transforms/parallel_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl TransformConfig for ParallelMapConfig {
for _ in 0..self.parallelism {
let transform_context_config = TransformContextConfig {
chain_name: "parallel_map_chain".into(),
protocol: transform_context.protocol,
up_chain_protocol: transform_context.up_chain_protocol,
};
chains.push(self.chain.get_builder(transform_context_config).await?);
}
Expand Down
2 changes: 1 addition & 1 deletion shotover/src/transforms/redis/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl TransformConfig for RedisConfig {

let transform_context_config = TransformContextConfig {
chain_name: "cache_chain".into(),
protocol: MessageType::Redis,
up_chain_protocol: MessageType::Redis,
};

Ok(Box::new(SimpleRedisCacheBuilder {
Expand Down
18 changes: 9 additions & 9 deletions shotover/src/transforms/tee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl TransformConfig for TeeConfig {
mismatch_chain
.get_builder(TransformContextConfig {
chain_name: "mismatch_chain".to_string(),
protocol: transform_context.protocol,
up_chain_protocol: transform_context.up_chain_protocol,
})
.await?,
)
Expand All @@ -214,7 +214,7 @@ impl TransformConfig for TeeConfig {
.chain
.get_builder(TransformContextConfig {
chain_name: "tee_chain".to_string(),
protocol: transform_context.protocol,
up_chain_protocol: transform_context.up_chain_protocol,
})
.await?;

Expand All @@ -224,7 +224,7 @@ impl TransformConfig for TeeConfig {
behavior,
self.timeout_micros,
self.switch_port,
transform_context.protocol.is_inorder(),
transform_context.up_chain_protocol.is_inorder(),
)))
}

Expand Down Expand Up @@ -606,7 +606,7 @@ mod tests {

let transform_context_config = TransformContextConfig {
chain_name: "".into(),
protocol: MessageType::Redis,
up_chain_protocol: MessageType::Redis,
};
let transform = config.get_builder(transform_context_config).await.unwrap();
let result = transform.validate();
Expand All @@ -625,7 +625,7 @@ mod tests {

let transform_context_config = TransformContextConfig {
chain_name: "".into(),
protocol: MessageType::Redis,
up_chain_protocol: MessageType::Redis,
};
let transform = config.get_builder(transform_context_config).await.unwrap();
let result = transform.validate().join("\n");
Expand All @@ -646,7 +646,7 @@ mod tests {
};
let transform_context_config = TransformContextConfig {
chain_name: "".into(),
protocol: MessageType::Redis,
up_chain_protocol: MessageType::Redis,
};
let transform = config.get_builder(transform_context_config).await.unwrap();
let result = transform.validate();
Expand All @@ -664,7 +664,7 @@ mod tests {
};
let transform_context_config = TransformContextConfig {
chain_name: "".into(),
protocol: MessageType::Redis,
up_chain_protocol: MessageType::Redis,
};
let transform = config.get_builder(transform_context_config).await.unwrap();
let result = transform.validate();
Expand All @@ -685,7 +685,7 @@ mod tests {

let transform_context_config = TransformContextConfig {
chain_name: "".into(),
protocol: MessageType::Redis,
up_chain_protocol: MessageType::Redis,
};
let transform = config.get_builder(transform_context_config).await.unwrap();
let result = transform.validate().join("\n");
Expand All @@ -709,7 +709,7 @@ mod tests {

let transform_context_config = TransformContextConfig {
chain_name: "".into(),
protocol: MessageType::Redis,
up_chain_protocol: MessageType::Redis,
};
let transform = config.get_builder(transform_context_config).await.unwrap();
let result = transform.validate();
Expand Down

0 comments on commit 723e852

Please sign in to comment.