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,75 @@
|
||||
#pragma once
|
||||
|
||||
// Supervisor plus background tasks plus replication log skeletons.
|
||||
// Gap: real 07-supervisor-replication.md owns worker processes, restarts,
|
||||
// durable streams, conflict handling, and multi-instance deployment.
|
||||
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace molo::example::fw {
|
||||
|
||||
struct WorkerInfo {
|
||||
std::string name;
|
||||
bool running = false;
|
||||
int restarts = 0;
|
||||
};
|
||||
|
||||
class Supervisor {
|
||||
public:
|
||||
void add_worker(const std::string& name);
|
||||
bool start(const std::string& name);
|
||||
bool stop(const std::string& name);
|
||||
bool restart(const std::string& name);
|
||||
std::vector<WorkerInfo> status() const;
|
||||
|
||||
private:
|
||||
mutable std::mutex mu_;
|
||||
std::map<std::string, WorkerInfo> workers_;
|
||||
};
|
||||
|
||||
struct TaskInfo {
|
||||
std::string id;
|
||||
std::string kind;
|
||||
std::string payload;
|
||||
std::string state;
|
||||
int attempts = 0;
|
||||
};
|
||||
|
||||
class TaskQueue {
|
||||
public:
|
||||
std::string enqueue(const std::string& kind, const std::string& payload,
|
||||
long delay_sec = 0);
|
||||
bool cancel(const std::string& id);
|
||||
bool retry(const std::string& id);
|
||||
void run_inline(TaskInfo& task);
|
||||
std::vector<TaskInfo> list() const;
|
||||
|
||||
private:
|
||||
mutable std::mutex mu_;
|
||||
std::map<std::string, TaskInfo> tasks_;
|
||||
unsigned long next_id_ = 1;
|
||||
};
|
||||
|
||||
struct ReplEntry {
|
||||
unsigned long seq = 0;
|
||||
std::string object;
|
||||
std::string data;
|
||||
std::string resolution;
|
||||
};
|
||||
|
||||
class ReplicationLog {
|
||||
public:
|
||||
ReplEntry append(const std::string& object, const std::string& data);
|
||||
std::vector<ReplEntry> since(unsigned long seq) const;
|
||||
unsigned long latest() const;
|
||||
|
||||
private:
|
||||
mutable std::mutex mu_;
|
||||
std::vector<ReplEntry> entries_;
|
||||
};
|
||||
|
||||
} // namespace molo::example::fw
|
||||
Reference in New Issue
Block a user