Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: pass SinkReplyBuilder and Transaction explicitly. Part10 #3998

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/server/dflycmd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ void DflyCmd::TakeOver(CmdArgList args, RedisReplyBuilder* rb, ConnectionContext
VLOG(1) << "Takeover accepted, shutting down.";
std::string save_arg = "NOSAVE";
MutableSlice sargs(save_arg);
return sf_->ShutdownCmd(CmdArgList(&sargs, 1), cntx);
return sf_->ShutdownCmd(CmdArgList(&sargs, 1), nullptr, rb, cntx);
}

void DflyCmd::Expire(CmdArgList args, RedisReplyBuilder* rb, ConnectionContext* cntx) {
Expand Down
2 changes: 1 addition & 1 deletion src/server/main_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1627,7 +1627,7 @@ void Service::DispatchMC(const MemcacheParser::Command& cmd, std::string_view va
strcpy(cmd_name, "QUIT");
break;
case MemcacheParser::STATS:
server_family_.StatsMC(cmd.key, cntx);
server_family_.StatsMC(cmd.key, mc_builder);
return;
case MemcacheParser::VERSION:
mc_builder->SendSimpleString("VERSION 1.5.0 DF");
Expand Down
14 changes: 7 additions & 7 deletions src/server/replica.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,18 @@ Replica::~Replica() {

static const char kConnErr[] = "could not connect to master: ";

error_code Replica::Start(ConnectionContext* cntx) {
error_code Replica::Start(facade::SinkReplyBuilder* builder) {
VLOG(1) << "Starting replication";
ProactorBase* mythread = ProactorBase::me();
CHECK(mythread);

auto check_connection_error = [this, &cntx](error_code ec, const char* msg) -> error_code {
auto check_connection_error = [this, builder](error_code ec, const char* msg) -> error_code {
if (cntx_.IsCancelled()) {
cntx->SendError("replication cancelled");
builder->SendError("replication cancelled");
return std::make_error_code(errc::operation_canceled);
}
if (ec) {
cntx->SendError(absl::StrCat(msg, ec.message()));
builder->SendError(absl::StrCat(msg, ec.message()));
cntx_.Cancel();
}
return ec;
Expand Down Expand Up @@ -131,17 +131,17 @@ error_code Replica::Start(ConnectionContext* cntx) {
// 4. Spawn main coordination fiber.
sync_fb_ = fb2::Fiber("main_replication", &Replica::MainReplicationFb, this);

cntx->SendOk();
builder->SendOk();
return {};
}

void Replica::EnableReplication(ConnectionContext* cntx) {
void Replica::EnableReplication(facade::SinkReplyBuilder* builder) {
VLOG(1) << "Enabling replication";

state_mask_.store(R_ENABLED); // set replica state to enabled
sync_fb_ = MakeFiber(&Replica::MainReplicationFb, this); // call replication fiber

cntx->SendOk();
builder->SendOk();
}

void Replica::Stop() {
Expand Down
4 changes: 2 additions & 2 deletions src/server/replica.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ class Replica : ProtocolClient {
// Spawns a fiber that runs until link with master is broken or the replication is stopped.
// Returns true if initial link with master has been established or
// false if it has failed.
std::error_code Start(ConnectionContext* cntx);
std::error_code Start(facade::SinkReplyBuilder* builder);

// Sets the server state to have replication enabled.
// It is like Start(), but does not attempt to establish
// a connection right-away, but instead lets MainReplicationFb do the work.
void EnableReplication(ConnectionContext* cntx);
void EnableReplication(facade::SinkReplyBuilder* builder);

void Stop(); // thread-safe

Expand Down
Loading
Loading