dragonfly/src/server/journal/executor.h
Roy Jacobson db21b735f6
feat(replication): Use a ring buffer with messages to serve replication. (#1835)
* feat(replication): Use a ring buffer with messages to serve replication.

* Fix libraries dep graph

* Address PR feedback

* nits

* add a comment

* Lower the default log length
2023-09-18 13:59:41 +03:00

42 lines
965 B
C++

// Copyright 2022, DragonflyDB authors. All rights reserved.
// See LICENSE for licensing terms.
//
#pragma once
#include <absl/types/span.h>
#include "facade/reply_capture.h"
#include "server/journal/types.h"
namespace dfly {
class Service;
// JournalExecutor allows executing journal entries.
class JournalExecutor {
public:
explicit JournalExecutor(Service* service);
~JournalExecutor();
JournalExecutor(JournalExecutor&&) = delete;
void Execute(DbIndex dbid, absl::Span<journal::ParsedEntry::CmdData> cmds);
void Execute(DbIndex dbid, journal::ParsedEntry::CmdData& cmd);
void FlushAll(); // Execute FLUSHALL.
private:
void Execute(journal::ParsedEntry::CmdData& cmd);
// Select database. Ensure it exists if accessed for first time.
void SelectDb(DbIndex dbid);
Service* service_;
facade::CapturingReplyBuilder reply_builder_;
ConnectionContext conn_context_;
std::vector<bool> ensured_dbs_;
};
} // namespace dfly