Class ResourceChangeNotifier
Defined in File resource_change_notifier.hpp
Nested Relationships
Nested Types
Class Documentation
-
class ResourceChangeNotifier
Central async notification hub for resource changes.
Producers (managers, plugins) call notify() to report resource changes. Observers (TriggerManager) register callbacks with filters. notify() is non-blocking - it pushes to an internal queue processed by a dedicated worker thread.
Public Types
-
using ErrorLoggerFn = std::function<void(const std::string&)>
Public Functions
-
explicit ResourceChangeNotifier(ErrorLoggerFn error_logger = {})
-
~ResourceChangeNotifier()
-
ResourceChangeNotifier(const ResourceChangeNotifier&) = delete
-
ResourceChangeNotifier &operator=(const ResourceChangeNotifier&) = delete
-
ResourceChangeNotifier(ResourceChangeNotifier&&) = delete
-
ResourceChangeNotifier &operator=(ResourceChangeNotifier&&) = delete
-
NotifierSubscriptionId subscribe(NotifierFilter filter, NotifierCallback callback)
Register a callback to be invoked when a matching resource change occurs.
- Parameters:
filter – Determines which changes trigger the callback
callback – Function called with the ResourceChange details
- Returns:
A unique subscription ID for later unsubscription
-
void unsubscribe(NotifierSubscriptionId id)
Remove a subscription by ID. No-op if ID not found.
-
void notify(const std::string &collection, const std::string &entity_id, const std::string &resource_path, const nlohmann::json &value, ChangeType change_type = ChangeType::UPDATED)
Report a resource change. Non-blocking - pushes to async work queue. After shutdown(), this is a no-op.
-
void shutdown()
Shut down the worker thread. After this, notify() is a no-op. Safe to call multiple times.
-
void set_max_queue_size(size_t max_size)
Set the maximum queue size. When exceeded, the oldest entries are dropped. Must be called before concurrent use (typically from GatewayNode init).
Public Static Attributes
-
static constexpr size_t kDefaultMaxQueueSize = 10000
Default maximum number of pending notifications in the queue.
-
using ErrorLoggerFn = std::function<void(const std::string&)>