Skip to content

Commit

Permalink
move NO ONE comparison to a function
Browse files Browse the repository at this point in the history
Signed-off-by: talbii <ido@dragonflydb.io>
  • Loading branch information
talbii committed Aug 8, 2023
1 parent 9f640c3 commit c3ed691
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/server/server_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,10 @@ void ValidateServerTlsFlags() {
}
}

bool IsReplicatingNoOne(string_view host, string_view port) {
return absl::EqualsIgnoreCase(host, "no") && absl::EqualsIgnoreCase(port, "one");
}

} // namespace

std::optional<SnapshotSpec> ParseSaveSchedule(string_view time) {
Expand Down Expand Up @@ -2063,7 +2067,7 @@ void ServerFamily::ReplicaOfInternal(string_view host, string_view port_sv, Conn
VLOG(1) << "Acquire replica lock";
unique_lock lk(replicaof_mu_);

if (absl::EqualsIgnoreCase(host, "no") && absl::EqualsIgnoreCase(port_sv, "one")) {
if (IsReplicatingNoOne(host, port_sv)) {
if (!ServerState::tlocal()->is_master) {
auto repl_ptr = replica_;
CHECK(repl_ptr);
Expand Down Expand Up @@ -2139,7 +2143,7 @@ void ServerFamily::ReplicaOf(CmdArgList args, ConnectionContext* cntx) {
string_view port = ArgS(args, 1);

// don't flush if input is NO ONE
if (!(absl::EqualsIgnoreCase(host, "NO") && absl::EqualsIgnoreCase(port, "ONE")))
if (!IsReplicatingNoOne(host, port))
Drakarys(cntx->transaction, DbSlice::kDbAll);

ReplicaOfInternal(host, port, cntx, ActionOnConnectionFail::kReturnOnError);
Expand Down

0 comments on commit c3ed691

Please sign in to comment.