aboutsummaryrefslogtreecommitdiff
path: root/src/resp_commands.rs
diff options
context:
space:
mode:
authoromagdy <omar.professional8777@gmail.com>2025-07-23 01:26:04 +0300
committeromagdy <omar.professional8777@gmail.com>2025-07-23 01:26:04 +0300
commitd4dbbda97b42bad8a41297ba1c3a693f1fe66902 (patch)
treeb240bfdbadb29330c193b53c094e99f4d007613d /src/resp_commands.rs
parentc94f86353dd98a176b61806eb4f25c9170c26717 (diff)
downloadredis-rust-d4dbbda97b42bad8a41297ba1c3a693f1fe66902.tar.xz
redis-rust-d4dbbda97b42bad8a41297ba1c3a693f1fe66902.zip
feat: Added replicationID and replicationOffset in info command for master nodes
Diffstat (limited to 'src/resp_commands.rs')
-rw-r--r--src/resp_commands.rs15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/resp_commands.rs b/src/resp_commands.rs
index 2ca9e02..2c9c09c 100644
--- a/src/resp_commands.rs
+++ b/src/resp_commands.rs
@@ -1,5 +1,5 @@
-use crate::SharedConfig;
use crate::{resp_parser::*, shared_cache::*};
+use crate::{RedisServer, SharedConfig};
use regex::Regex;
use std::time::{SystemTime, UNIX_EPOCH};
@@ -237,11 +237,18 @@ impl RedisCommands {
RC::Info(_sub_command) => {
use RespType as RT;
let config = config.clone();
- let mut role = "master".to_string();
+ let mut server = RedisServer::new();
if let Some(conf) = config.as_ref() {
- role = conf.server.clone().role;
+ server = conf.server.clone();
}
- let response = format!("# Replication\r\nrole:{role}",).as_bytes().to_vec();
+ let response = format!(
+ "# Replication\r\nrole:{}master_replid:{}master_repl_offset:{}",
+ server.role,
+ server.master_replid.unwrap_or("".to_string()),
+ server.master_repl_offset.unwrap_or("".to_string())
+ )
+ .as_bytes()
+ .to_vec();
RT::BulkString(response).to_resp_bytes()
}
RC::Invalid => todo!(),