#pragma once #include #include #include #include #include #include namespace DB { class InMemoryLogStore : public nuraft::log_store { public: InMemoryLogStore(); uint64_t start_index() const override; uint64_t next_slot() const override; nuraft::ptr last_entry() const override; uint64_t append(nuraft::ptr & entry) override; void write_at(uint64_t index, nuraft::ptr & entry) override; nuraft::ptr>> log_entries(uint64_t start, uint64_t end) override; nuraft::ptr entry_at(uint64_t index) override; uint64_t term_at(uint64_t index) override; nuraft::ptr pack(uint64_t index, Int32 cnt) override; void apply_pack(uint64_t index, nuraft::buffer & pack) override; bool compact(uint64_t last_log_index) override; bool flush() override { return true; } private: std::map> logs TSA_GUARDED_BY(logs_lock); mutable std::mutex logs_lock; std::atomic start_idx; }; }