From b7efe705e2865fa89cd3d3bfd3926fdb9667847d Mon Sep 17 00:00:00 2001 From: omagdy Date: Wed, 23 Jul 2025 03:20:14 +0300 Subject: feat: Implemented last step of handshake process --- src/resp_commands.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/resp_commands.rs') diff --git a/src/resp_commands.rs b/src/resp_commands.rs index dcb717f..04d304c 100644 --- a/src/resp_commands.rs +++ b/src/resp_commands.rs @@ -118,6 +118,7 @@ pub enum RedisCommands { Keys(String), Info(String), ReplConf((String, String)), + Psync((String, String)), Invalid, } @@ -255,6 +256,18 @@ impl RedisCommands { RC::ReplConf((_, _)) => { resp_bytes!("OK") } + RC::Psync((_, _)) => { + let config = config.clone(); + let mut server = RedisServer::new(); + if let Some(conf) = config.as_ref() { + server = conf.server.clone(); + } + let response = format!( + "FULLRESYNC {} 0", + server.master_replid.unwrap_or("".to_string()), + ); + resp_bytes!(response) + } RC::Invalid => todo!(), } } @@ -445,6 +458,15 @@ impl From for RedisCommands { }; Self::ReplConf((op1, op2)) } + "PSYNC" => { + let Some(repl_id) = args.next() else { + return Self::Invalid; + }; + let Some(repl_offset) = args.next() else { + return Self::Invalid; + }; + Self::Psync((repl_id, repl_offset)) + } _ => Self::Invalid, } } -- cgit v1.2.3