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,51 @@
|
||||
#pragma once
|
||||
// FeatureFlags holds global flag defaults with per-tenant overrides.
|
||||
// Bounded at kFlagsMax definitions; unknown flags read as false.
|
||||
|
||||
#include <cstddef>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "tenancy/caps.h"
|
||||
|
||||
namespace molo::tenancy {
|
||||
|
||||
class FeatureFlags {
|
||||
public:
|
||||
bool define(const std::string& name, bool default_value) {
|
||||
std::lock_guard<std::mutex> lock(mu_);
|
||||
if (defaults_.find(name) == defaults_.end() && defaults_.size() >= Caps::kFlagsMax) {
|
||||
return false;
|
||||
}
|
||||
defaults_[name] = default_value;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool set_tenant(const std::string& slug, const std::string& name, bool value) {
|
||||
std::lock_guard<std::mutex> lock(mu_);
|
||||
if (defaults_.find(name) == defaults_.end()) return false;
|
||||
overrides_[slug + '\x1f' + name] = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool enabled(const std::string& slug, const std::string& name) const {
|
||||
std::lock_guard<std::mutex> lock(mu_);
|
||||
auto ov = overrides_.find(slug + '\x1f' + name);
|
||||
if (ov != overrides_.end()) return ov->second;
|
||||
auto def = defaults_.find(name);
|
||||
return def == defaults_.end() ? false : def->second;
|
||||
}
|
||||
|
||||
std::size_t count() const {
|
||||
std::lock_guard<std::mutex> lock(mu_);
|
||||
return defaults_.size();
|
||||
}
|
||||
|
||||
private:
|
||||
mutable std::mutex mu_;
|
||||
std::unordered_map<std::string, bool> defaults_;
|
||||
std::unordered_map<std::string, bool> overrides_;
|
||||
};
|
||||
|
||||
} // namespace molo::tenancy
|
||||
Reference in New Issue
Block a user