|
Database System 0.1.0
Advanced C++20 Database System with Multi-Backend Support
|
Real-time data stream processing. More...
#include <async_operations.h>

Classes | |
| struct | stream_event |
Public Types | |
| enum class | stream_type { postgresql_notify , mongodb_change_stream , redis_pubsub , custom } |
Public Member Functions | |
| stream_processor (std::shared_ptr< core::database_backend > db) | |
| ~stream_processor () | |
| bool | start_stream (stream_type type, const std::string &channel) |
| bool | stop_stream (const std::string &channel) |
| void | stop_all_streams () |
| template<concepts::StreamEventHandler< stream_event > Handler> | |
| void | register_event_handler (const std::string &channel, Handler &&handler) |
| template<concepts::StreamEventHandler< stream_event > Handler> | |
| void | register_global_handler (Handler &&handler) |
| void | register_event_handler (const std::string &channel, std::function< void(const stream_event &)> handler) |
| void | register_global_handler (std::function< void(const stream_event &)> handler) |
| template<concepts::StreamEventFilter< stream_event > Filter> | |
| void | add_event_filter (const std::string &channel, Filter &&filter) |
| void | add_event_filter (const std::string &channel, std::function< bool(const stream_event &)> filter) |
Private Member Functions | |
| void | stream_thread (const std::string &channel, stream_type type) |
| void | process_event (const stream_event &event) |
Private Attributes | |
| std::shared_ptr< core::database_backend > | db_ |
| std::mutex | threads_mutex_ |
| std::unordered_map< std::string, std::thread > | stream_threads_ |
| std::mutex | handlers_mutex_ |
| std::unordered_map< std::string, std::function< void(const stream_event &)> > | event_handlers_ |
| std::vector< std::function< void(const stream_event &)> > | global_handlers_ |
| std::unordered_map< std::string, std::function< bool(const stream_event &)> > | event_filters_ |
| std::atomic< bool > | running_ {true} |
Real-time data stream processing.
Thread-safety: All public methods are thread-safe. Event handlers are called from dedicated stream threads, so handlers must be thread-safe if they access shared state. The handlers_mutex_ protects all handler registration and filter operations.
Definition at line 563 of file async_operations.h.
|
strong |
| Enumerator | |
|---|---|
| postgresql_notify | |
| mongodb_change_stream | |
| redis_pubsub | |
| custom | |
Definition at line 566 of file async_operations.h.
|
inline |
Definition at line 1142 of file async_operations.h.
|
inline |
Definition at line 1148 of file async_operations.h.
References stop_all_streams().

|
inline |
Definition at line 613 of file async_operations.h.
References event_filters_, and handlers_mutex_.
|
inline |
Definition at line 1216 of file async_operations.h.
References event_filters_, and handlers_mutex_.
|
inlineprivate |
Definition at line 1245 of file async_operations.h.
References database::async::stream_processor::stream_event::channel, event_filters_, event_handlers_, global_handlers_, and handlers_mutex_.
Referenced by stream_thread().

|
inline |
Definition at line 592 of file async_operations.h.
References event_handlers_, and handlers_mutex_.
|
inline |
Definition at line 1201 of file async_operations.h.
References event_handlers_, and handlers_mutex_.
|
inline |
Definition at line 599 of file async_operations.h.
References global_handlers_, and handlers_mutex_.
|
inline |
Definition at line 1209 of file async_operations.h.
References global_handlers_, and handlers_mutex_.
|
inline |
Definition at line 1153 of file async_operations.h.
References stream_thread(), stream_threads_, and threads_mutex_.
Referenced by TEST_F().


|
inline |
Definition at line 1185 of file async_operations.h.
References running_, stream_threads_, and threads_mutex_.
Referenced by ~stream_processor().

|
inline |
Definition at line 1166 of file async_operations.h.
References stream_threads_, and threads_mutex_.
|
inlineprivate |
Definition at line 1224 of file async_operations.h.
References database::async::stream_processor::stream_event::channel, database::async::stream_processor::stream_event::payload, process_event(), running_, stream_threads_, threads_mutex_, database::async::stream_processor::stream_event::timestamp, and database::async::stream_processor::stream_event::type.
Referenced by start_stream().


|
private |
Definition at line 627 of file async_operations.h.
|
private |
Definition at line 633 of file async_operations.h.
Referenced by add_event_filter(), add_event_filter(), and process_event().
|
private |
Definition at line 631 of file async_operations.h.
Referenced by process_event(), register_event_handler(), and register_event_handler().
|
private |
Definition at line 632 of file async_operations.h.
Referenced by process_event(), register_global_handler(), and register_global_handler().
|
private |
Definition at line 630 of file async_operations.h.
Referenced by add_event_filter(), add_event_filter(), process_event(), register_event_handler(), register_event_handler(), register_global_handler(), and register_global_handler().
|
private |
Definition at line 634 of file async_operations.h.
Referenced by stop_all_streams(), and stream_thread().
|
private |
Definition at line 629 of file async_operations.h.
Referenced by start_stream(), stop_all_streams(), stop_stream(), and stream_thread().
|
private |
Definition at line 628 of file async_operations.h.
Referenced by start_stream(), stop_all_streams(), stop_stream(), and stream_thread().