Skip to content

Commit 23d994b

Browse files
committed
fix: resolve merge conflict
Signed-off-by: Eun-chan Cho <eunchan.cho@talabat.com>
1 parent 15ec8b9 commit 23d994b

11 files changed

Lines changed: 22 additions & 27 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ tp = duva.tp
88
cli:
99
@echo '🚀 Starting client in local_test/cli...'
1010
@mkdir -p local_test/cli
11-
@cd local_test/cli && cargo run --bin duva-cli -- --port $(p)
11+
@cd local_test/cli && cargo run --bin cli -- --port $(p)
1212

1313
leader:
1414
@echo '🔧 Setting up replication with leader on port $(p) and follower on port $(rp)...'

duva-cli/src/command.rs

Whitespace-only changes.

duva-client/src/command.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ pub fn take_input(action: &str, args: &[&str]) -> Result<ClientInputKind, String
8181
}
8282
Err("(error) ERR unknown subcommand".to_string())
8383
},
84+
"REPLICAOF" => {
85+
if args.len() != 3 {
86+
return Err(
87+
"(error) ERR wrong number of arguments for 'replicaof' command".to_string()
88+
);
89+
};
90+
Ok(ClientInputKind::ReplicaOf)
91+
},
8492

8593
// Add other commands as needed
8694
unknown_cmd => {
@@ -104,4 +112,5 @@ pub enum ClientInputKind {
104112
ClusterNodes,
105113
ClusterForget,
106114
Exists,
115+
ReplicaOf,
107116
}

duva-client/src/controller.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ impl<T> ClientController<T> {
180180
use ClientInputKind::*;
181181
match input {
182182
Ping | Get | IndexGet | Echo | Config | Keys | Save | Info | ClusterForget
183-
| ClusterInfo => match query_io {
183+
| ReplicaOf | ClusterInfo => match query_io {
184184
QueryIO::Null => println!("(nil)"),
185185
QueryIO::SimpleString(value) => println!("{value}"),
186186
QueryIO::BulkString(value) => println!("{value}"),

duva/src/presentation/clients/parser.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use anyhow::Context;
22
use chrono::{DateTime, Utc};
33

4-
use crate::domains::cluster_actors::session::SessionRequest;
5-
64
use super::request::{ClientAction, ClientRequest};
5+
use crate::domains::cluster_actors::session::SessionRequest;
6+
use crate::prelude::PeerIdentifier;
77

88
/// Analyze the command and arguments to create a `ClientRequest`
99
pub fn parse_query(
@@ -49,7 +49,9 @@ pub fn parse_query(
4949
"forget" => ClientAction::ClusterForget(val.get(1).cloned().context("Must")?.into()),
5050
_ => return Err(anyhow::anyhow!("Invalid command")),
5151
},
52-
52+
("replicaof", [host, port]) => {
53+
ClientAction::ReplicaOf(PeerIdentifier::new(host, port.parse()?))
54+
},
5355
_ => return Err(anyhow::anyhow!("Invalid command")),
5456
};
5557

duva/src/presentation/clients/stream.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use super::request::{ClientAction, ClientRequest};
2-
use crate::domains::peers::identifier::PeerIdentifier;
31
use super::{parser::parse_query, request::ClientRequest};
42
use crate::{
53
TSerdeReadWrite,

duva/tests/cluster_ops/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ mod test_cluster_known_nodes_increase_when_new_replica_is_added;
44
mod test_disseminate_peers;
55
mod test_heartbeat;
66
mod test_removes_node_when_heartbeat_is_not_received_for_certain_time;
7+
8+
mod test_lazy_discovery;

duva/tests/cluster_ops/test_cluster_forget_makes_all_nodes_forget_target_node.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
use crate::common::{ServerEnv, array, check_internodes_communication, spawn_server_process};
22

33
use duva::{clients::ClientStreamHandler, domains::query_parsers::query_io::QueryIO};
4-
mod common;
5-
use crate::common::bulk_string;
6-
use common::{ServerEnv, array, check_internodes_communication, spawn_server_process};
7-
use duva::clients::ClientStreamHandler;
84

95
#[tokio::test]
106
async fn test_cluster_forget_makes_all_nodes_forget_target_node() {

duva/tests/cluster_ops/test_cluster_known_nodes_increase_when_new_replica_is_added.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
mod common;
2-
use crate::common::bulk_string;
3-
use common::{ServerEnv, array, spawn_server_process};
4-
use duva::clients::ClientStreamHandler;
51
use crate::common::{ServerEnv, array, spawn_server_process};
62
use duva::{clients::ClientStreamHandler, domains::query_parsers::query_io::QueryIO};
73

duva/tests/test_lazy_discovery.rs renamed to duva/tests/cluster_ops/test_lazy_discovery.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
use crate::common::{array, bulk_string, contains_only};
2-
use common::{ServerEnv, spawn_server_process};
1+
use crate::common::{ServerEnv, array, contains_only, spawn_server_process};
32
use duva::clients::ClientStreamHandler;
4-
5-
mod common;
3+
use duva::domains::query_parsers::query_io::QueryIO;
64

75
#[tokio::test]
86
async fn test_lazy_discovery_of_leader() {
@@ -27,7 +25,7 @@ async fn test_lazy_discovery_of_leader() {
2725
other_h.send_and_get(&array(vec!["SET", "other2", "value2"])).await;
2826

2927
let cluster_info = other_h.send_and_get(&array(vec!["CLUSTER", "INFO"])).await;
30-
assert_eq!(cluster_info, bulk_string("cluster_known_nodes:0"));
28+
assert_eq!(cluster_info, QueryIO::BulkString("cluster_known_nodes:0".into()).serialize());
3129

3230
assert!(contains_only(
3331
other_h.send_and_get(&array(vec!["KEYS", "*"])).await,
@@ -44,7 +42,7 @@ async fn test_lazy_discovery_of_leader() {
4442

4543
// THEN
4644
let cluster_info = other_h.send_and_get(&array(vec!["CLUSTER", "INFO"])).await;
47-
assert_eq!(cluster_info, bulk_string("cluster_known_nodes:1"));
45+
assert_eq!(cluster_info, QueryIO::BulkString("cluster_known_nodes:1".into()).serialize());
4846

4947
let response = target_h.send_and_get(&array(vec!["KEYS", "*"])).await;
5048
assert!(contains_only(response, vec!["other", "other2"]));

0 commit comments

Comments
 (0)