diff options
| author | omagdy <omar.professional8777@gmail.com> | 2025-07-23 01:11:12 +0300 |
|---|---|---|
| committer | omagdy <omar.professional8777@gmail.com> | 2025-07-23 01:11:12 +0300 |
| commit | c94f86353dd98a176b61806eb4f25c9170c26717 (patch) | |
| tree | 8425cb5ed8733a979aa3618fea8fc9bb957aedc3 /src/resp_commands.rs | |
| parent | 7dbaa99eb721748f5eff2839817c6742029ad2b3 (diff) | |
| download | redis-rust-c94f86353dd98a176b61806eb4f25c9170c26717.tar.xz redis-rust-c94f86353dd98a176b61806eb4f25c9170c26717.zip | |
feat: Added simple logic to check if redis node role is master or slave
Diffstat (limited to 'src/resp_commands.rs')
| -rw-r--r-- | src/resp_commands.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/resp_commands.rs b/src/resp_commands.rs index 0fa6945..2ca9e02 100644 --- a/src/resp_commands.rs +++ b/src/resp_commands.rs @@ -236,7 +236,13 @@ impl RedisCommands { } RC::Info(_sub_command) => { use RespType as RT; - RT::BulkString("# Replication\r\nrole:master".as_bytes().to_vec()).to_resp_bytes() + let config = config.clone(); + let mut role = "master".to_string(); + if let Some(conf) = config.as_ref() { + role = conf.server.clone().role; + } + let response = format!("# Replication\r\nrole:{role}",).as_bytes().to_vec(); + RT::BulkString(response).to_resp_bytes() } RC::Invalid => todo!(), } |
