feat: implement MoloApp plans 01-15 with integration
Full C++23 framework tree: runtime, observability, security, data, app, realtime, supervisor, clients, CLI, example plus enterprise tenancy, audit, operability, governance, supplychain. Postgres via docker compose for tests.
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include "supervisor/replication/hybrid_clock.hpp"
|
||||
|
||||
namespace molo::replication {
|
||||
|
||||
class ReplicationError : public std::runtime_error {
|
||||
public:
|
||||
explicit ReplicationError(const std::string& message) : std::runtime_error(message) {}
|
||||
};
|
||||
|
||||
// Raised to the loser of an optimistic-locking conflict, carrying the
|
||||
// winner version so the caller can re-read and retry (S7-8).
|
||||
class ConflictError : public ReplicationError {
|
||||
public:
|
||||
ConflictError(const std::string& model, const std::string& key, long long winner_version)
|
||||
: ReplicationError("conflict:" + model + ":" + key),
|
||||
model_(model),
|
||||
key_(key),
|
||||
winner_version_(winner_version) {}
|
||||
|
||||
const std::string& model() const { return model_; }
|
||||
const std::string& key() const { return key_; }
|
||||
long long winner_version() const { return winner_version_; }
|
||||
|
||||
private:
|
||||
std::string model_;
|
||||
std::string key_;
|
||||
long long winner_version_;
|
||||
};
|
||||
|
||||
enum class OplogOp {
|
||||
Upsert,
|
||||
Delete,
|
||||
};
|
||||
|
||||
std::string to_string(OplogOp op);
|
||||
bool parse_oplog_op(const std::string& text, OplogOp& out);
|
||||
|
||||
// One replication log entry (S7-7):
|
||||
// {"seq":n,"instance":"id","ts":"hybrid-clock","model":"name","key":"pk",
|
||||
// "op":"upsert|delete","version":n,"data":{}}
|
||||
struct OplogEntry {
|
||||
std::uint64_t seq = 0;
|
||||
std::string instance;
|
||||
HybridTs ts;
|
||||
std::string model;
|
||||
std::string key;
|
||||
OplogOp op = OplogOp::Upsert;
|
||||
long long version = 0;
|
||||
std::string data = "{}"; // opaque JSON object, owned by the model layer
|
||||
|
||||
std::string encode() const;
|
||||
static bool decode(const std::string& text, OplogEntry& out);
|
||||
std::size_t approx_bytes() const;
|
||||
};
|
||||
|
||||
} // namespace molo::replication
|
||||
Reference in New Issue
Block a user