SharedStorage/utils/io/RecoveryLog.h

42 lines
850 B
C++

//
// Created by Kirill Zhukov on 20.04.2025.
//
#ifndef RECOVERYLOG_H
#define RECOVERYLOG_H
#include <fstream>
#include <iostream>
#include <string>
#include <functional>
#include "utils/hash/Hash128.h"
namespace usub::utils
{
class RecoveryLog
{
public:
explicit RecoveryLog(const std::string& dbname);
~RecoveryLog();
void log_put(const std::string& key, const std::string& value);
void log_delete(const std::string& key);
void replay(const std::function<void(const Hash128& key, const std::string& value, bool is_tombstone)>& callback) const;
private:
void ensure_metadata_dir() const;
private:
std::string db_name;
std::string metadata_dir;
std::string log_file;
std::ofstream log_out;
};
} // utils
// usub
#endif //RECOVERYLOG_H