Skip to content

Commit

Permalink
feat(server): monitor command should return OK on creation (dragonfly…
Browse files Browse the repository at this point in the history
…db#344)

Signed-off-by: Boaz Sade <[email protected]>
  • Loading branch information
boazsade committed Oct 25, 2022
1 parent e4357e1 commit 5228ab8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/server/main_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@ auto CmdEntryToMonitorFormat(std::string_view str) -> std::string {

std::string MakeMonitorMessage(const ConnectionState& conn_state,
const facade::Connection* connection, CmdArgList args) {
std::string message = CreateMonitorTimestamp();
std::string message = absl::StrCat(CreateMonitorTimestamp(), " [", conn_state.db_index);

if (conn_state.script_info.has_value()) {
absl::StrAppend(&message, "lua] ");
absl::StrAppend(&message, " lua] ");
} else {
absl::StrAppend(&message, connection->RemoteEndpointStr());
absl::StrAppend(&message, " ", connection->RemoteEndpointStr(), "] ");
}
if (args.empty()) {
absl::StrAppend(&message, "error - empty cmd list!");
Expand Down Expand Up @@ -1293,6 +1293,7 @@ void Service::Monitor(CmdArgList args, ConnectionContext* cntx) {
VLOG(1) << "starting monitor on this connection: " << cntx->owner()->GetClientInfo();
// we are registering the current connection for all threads so they will be aware of
// this connection, to send to it any command
(*cntx)->SendOk();
cntx->ChangeMonitor(true /* start */);
}

Expand Down

0 comments on commit 5228ab8

Please sign in to comment.