|
ORE Studio 0.0.4
|
Event source that bridges PostgreSQL LISTEN/NOTIFY to the event bus. More...
#include <postgres_event_source.hpp>

Public Member Functions | |
| postgres_event_source (database::context ctx, event_bus &bus) | |
| Constructs a postgres_event_source. | |
| postgres_event_source (const postgres_event_source &)=delete | |
| postgres_event_source & | operator= (const postgres_event_source &)=delete |
| template<typename Event > | |
| void | register_mapping (const std::string &entity_name, const std::string &channel_name) |
| Register a mapping from entity name to typed domain event. | |
| void | start () |
| Start the event source. | |
| void | stop () |
| Stop the event source. | |
Event source that bridges PostgreSQL LISTEN/NOTIFY to the event bus.
This class wraps postgres_listener_service and translates low-level entity_change_event notifications into typed domain events that are published to the event bus.
Components can register their entity-to-event mappings via register_mapping(), enabling the event source to automatically publish the correct typed event when a database notification is received.
Usage:
| postgres_event_source | ( | database::context | ctx, |
| event_bus & | bus | ||
| ) |
Constructs a postgres_event_source.
| ctx | Database context for the listener connection. |
| bus | Reference to the event bus for publishing events. |
| void register_mapping | ( | const std::string & | entity_name, |
| const std::string & | channel_name | ||
| ) |
Register a mapping from entity name to typed domain event.
When a notification is received for the specified entity, the event source will publish an instance of Event to the bus with the notification's timestamp.
| Event | The domain event type to publish (must have a timestamp member). |
| entity_name | The fully qualified entity name (e.g., "ores.risk.currency"). |
| channel_name | The PostgreSQL channel to listen on (e.g., "ores_currencies"). |

| void start | ( | ) |
Start the event source.
Begins listening for PostgreSQL notifications on all registered channels.
| void stop | ( | ) |
Stop the event source.
Stops listening for notifications.