Skip to content

Commit

Permalink
Update Redis to Valkey Part 2 (#1830)
Browse files Browse the repository at this point in the history
Co-authored-by: Lucas Kent <[email protected]>
  • Loading branch information
ronycsdu and rukai authored Nov 22, 2024
1 parent 395ca02 commit 2bb4ed3
Show file tree
Hide file tree
Showing 61 changed files with 428 additions and 431 deletions.
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ windsock = "test --release --bench windsock --features kafka,alpha-transforms,ka
windsock-debug = "test --bench windsock --features kafka,alpha-transforms,kafka-cpp-driver-tests,cassandra,redis --"

# Can only run benchmarks specific to the protocol but compiles a lot faster
windsock-redis = "test --release --bench windsock --no-default-features --features redis,alpha-transforms --"
windsock-valkey = "test --release --bench windsock --no-default-features --features redis,alpha-transforms --"
windsock-kafka = "test --release --bench windsock --no-default-features --features kafka,alpha-transforms,kafka-cpp-driver-tests --"
windsock-cassandra = "test --release --bench windsock --no-default-features --features cassandra,alpha-transforms --"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windsock_benches.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
cargo windsock local-run --bench-length-seconds 5 --operations-per-second 100 --profilers flamegraph db=cassandra,compression=none,connection_count=1,driver=scylla,operation=read_i64,protocol=v4,shotover=standard,topology=single
cargo windsock local-run --bench-length-seconds 5 --operations-per-second 100 --profilers samply db=cassandra,compression=none,connection_count=1,driver=scylla,operation=read_i64,protocol=v4,shotover=standard,topology=single
cargo windsock local-run --bench-length-seconds 5 --operations-per-second 100 --profilers sys_monitor db=kafka,shotover=standard,size=12B,topology=single
cargo windsock local-run --bench-length-seconds 5 --operations-per-second 100 --profilers shotover_metrics db=redis,encryption=none,operation=get,shotover=standard,topology=single
cargo windsock local-run --bench-length-seconds 5 --operations-per-second 100 --profilers shotover_metrics db=valkey,encryption=none,operation=get,shotover=standard,topology=single
- name: Ensure that tests did not create or modify any files that arent .gitignore'd
run: |
if [ -n "$(git status --porcelain)" ]; then
Expand Down
6 changes: 3 additions & 3 deletions custom-transforms-example/config/topology.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
sources:
- Valkey:
name: "redis"
name: "valkey"
listen_addr: "127.0.0.1:6379"
chain:
- RedisGetRewrite:
- ValkeyGetRewrite:
result: "Rewritten value"
- RedisSinkSingle:
- ValkeySinkSingle:
remote_address: "127.0.0.1:1111"
connect_timeout_ms: 3000
2 changes: 1 addition & 1 deletion custom-transforms-example/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use shotover::runner::Shotover;
#[cfg(feature = "redis")]
mod redis_get_rewrite;
#[cfg(feature = "redis")]
shotover::import_transform!(redis_get_rewrite::RedisGetRewriteConfig);
shotover::import_transform!(redis_get_rewrite::ValkeyGetRewriteConfig);

fn main() {
Shotover::new().run_block();
Expand Down
20 changes: 10 additions & 10 deletions custom-transforms-example/src/redis_get_rewrite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ use shotover::transforms::{DownChainProtocol, TransformContextBuilder, UpChainPr

#[derive(Serialize, Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct RedisGetRewriteConfig {
pub struct ValkeyGetRewriteConfig {
pub result: String,
}

const NAME: &str = "RedisGetRewrite";
#[typetag::serde(name = "RedisGetRewrite")]
const NAME: &str = "ValkeyGetRewrite";
#[typetag::serde(name = "ValkeyGetRewrite")]
#[async_trait(?Send)]
impl TransformConfig for RedisGetRewriteConfig {
impl TransformConfig for ValkeyGetRewriteConfig {
async fn get_builder(
&self,
_transform_context: TransformContextConfig,
) -> Result<Box<dyn TransformBuilder>> {
Ok(Box::new(RedisGetRewriteBuilder {
Ok(Box::new(ValkeyGetRewriteBuilder {
result: self.result.clone(),
}))
}
Expand All @@ -36,13 +36,13 @@ impl TransformConfig for RedisGetRewriteConfig {
}
}

pub struct RedisGetRewriteBuilder {
pub struct ValkeyGetRewriteBuilder {
result: String,
}

impl TransformBuilder for RedisGetRewriteBuilder {
impl TransformBuilder for ValkeyGetRewriteBuilder {
fn build(&self, _transform_context: TransformContextBuilder) -> Box<dyn Transform> {
Box::new(RedisGetRewrite {
Box::new(ValkeyGetRewrite {
get_requests: MessageIdSet::default(),
result: self.result.clone(),
})
Expand All @@ -53,13 +53,13 @@ impl TransformBuilder for RedisGetRewriteBuilder {
}
}

pub struct RedisGetRewrite {
pub struct ValkeyGetRewrite {
get_requests: MessageIdSet,
result: String,
}

#[async_trait]
impl Transform for RedisGetRewrite {
impl Transform for ValkeyGetRewrite {
fn get_name(&self) -> &'static str {
NAME
}
Expand Down
2 changes: 1 addition & 1 deletion custom-transforms-example/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use test_helpers::shotover_process::{bin_path, BinProcess, EventMatcher, Level};

#[tokio::test(flavor = "multi_thread")]
async fn test_custom_transform() {
// Setup shotover and the redis server it connects to
// Setup shotover and the valkey server it connects to
let _compose = docker_compose("config/docker-compose.yaml");
let shotover = shotover_proxy("config/topology.yaml").await;
let mut connection = redis_connection::new_async("127.0.0.1", 6379).await;
Expand Down
10 changes: 5 additions & 5 deletions ec2-cargo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ fi
),
);
shell.commands.insert(
"windsock-redis",
"windsock-valkey",
Command::new_async(
"Uploads changes and runs `cargo windsock-redis $args`. Windsock results are downloaded to target/windsock_data".to_owned(),
async_fn!(State, windsock_redis),
"Uploads changes and runs `cargo windsock-valkey $args`. Windsock results are downloaded to target/windsock_data".to_owned(),
async_fn!(State, windsock_valkey),
),
);
shell.commands.insert(
Expand Down Expand Up @@ -212,8 +212,8 @@ async fn windsock_cassandra(state: &mut State, args: Vec<String>) -> Result<(),
windsock_inner("windsock-cassandra", state, args).await
}

async fn windsock_redis(state: &mut State, args: Vec<String>) -> Result<(), Box<dyn Error>> {
windsock_inner("windsock-redis", state, args).await
async fn windsock_valkey(state: &mut State, args: Vec<String>) -> Result<(), Box<dyn Error>> {
windsock_inner("windsock-valkey", state, args).await
}

async fn windsock_inner(
Expand Down
Loading

0 comments on commit 2bb4ed3

Please sign in to comment.