Add async/resilience/reflection primitives + FSM v2 rewrite
A round of new universal capabilities (all generic — templated/reflection based, no app coupling), verified by the test suite (1103 passing): Data reflection: - Reflect.hpp now (de)serializes chrono::duration, chrono::time_point, std::variant (tagged), std::array, and non-string-keyed std::map; Meta.hpp gains is_time_point_v et al. Async: - EventBus gains Mode::Async (worker-thread dispatch + flush()). - ThreadPool gains a bounded queue, try_submit(), and rejection stats. New modules / containers: - Resilience: TokenBucket, KeyedRateLimiter<Key>, CircuitBreaker, ResourceMonitor. - Containers: BufferPool<T> (size-class buffer reuse) and Cache<K,V> (per-entry TTL, LRU/LFU/FIFO eviction, hit/miss stats). - System: process/CPU/memory metrics (Metrics.hpp) and a streaming Process API. Plus FSM v2 (typed Success/Failure, sub-machines, parallel regions, history states, deferred events), Configuration/Logging reflection helpers, and the accompanying test suites. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
43b5a81504
commit
80293ee56f
93 files changed
+8500
-3312
No files matched your search
@@ -0,0 +1,70 @@
|
||||
#include <Void/Service/Registry.hpp>
|
||||
#include <Void/Testing/Assert.hpp>
|
||||
#include <Void/Testing/Suite.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace
|
||||
{
|
||||
using Void::Service::ServiceRegistry;
|
||||
using Void::Testing::Test;
|
||||
|
||||
struct IGreeter {
|
||||
virtual ~IGreeter() = default;
|
||||
virtual int id() const = 0;
|
||||
};
|
||||
struct Greeter : IGreeter {
|
||||
int v;
|
||||
explicit Greeter(int x) : v{x} {}
|
||||
int id() const override { return v; }
|
||||
};
|
||||
|
||||
struct IOther {
|
||||
virtual ~IOther() = default;
|
||||
};
|
||||
struct Other : IOther {
|
||||
};
|
||||
|
||||
struct ScopedRegistry : Void::Testing::Suite<ScopedRegistry> {
|
||||
Test child_falls_through_to_parent()
|
||||
{
|
||||
ServiceRegistry parent;
|
||||
parent.provide<IGreeter>(std::make_shared<Greeter>(1));
|
||||
|
||||
ServiceRegistry child{&parent};
|
||||
Void::Testing::expect(child.has<IGreeter>());
|
||||
Void::Testing::expect_eq(child.require<IGreeter>().id(), 1);
|
||||
}
|
||||
|
||||
Test child_shadows_parent()
|
||||
{
|
||||
ServiceRegistry parent;
|
||||
parent.provide<IGreeter>(std::make_shared<Greeter>(1));
|
||||
|
||||
ServiceRegistry child{&parent};
|
||||
child.provide<IGreeter>(std::make_shared<Greeter>(2));
|
||||
|
||||
Void::Testing::expect_eq(child.require<IGreeter>().id(), 2);
|
||||
// Parent is untouched.
|
||||
Void::Testing::expect_eq(parent.require<IGreeter>().id(), 1);
|
||||
}
|
||||
|
||||
Test child_local_provide_invisible_to_parent()
|
||||
{
|
||||
ServiceRegistry parent;
|
||||
ServiceRegistry child{&parent};
|
||||
child.provide<IOther>(std::make_shared<Other>());
|
||||
|
||||
Void::Testing::expect(child.has<IOther>());
|
||||
Void::Testing::expect(!parent.has<IOther>());
|
||||
}
|
||||
|
||||
Test miss_in_both_returns_nullptr()
|
||||
{
|
||||
ServiceRegistry parent;
|
||||
ServiceRegistry child{&parent};
|
||||
Void::Testing::expect(child.get<IGreeter>() == nullptr);
|
||||
Void::Testing::expect(!child.has<IGreeter>());
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
Reference in new issue
Block a user