From 619b49ee6cd005cfeb2ab889a1467c665cf9691d Mon Sep 17 00:00:00 2001 From: Taha Afzal Date: Wed, 15 Nov 2023 12:30:43 +0000 Subject: [PATCH] Changing the stream subscription structure --- src/lib/datastreams/Tables/StreamData.h | 37 ++++++++++++++++++++----- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/src/lib/datastreams/Tables/StreamData.h b/src/lib/datastreams/Tables/StreamData.h index e3d499301..385a60e69 100644 --- a/src/lib/datastreams/Tables/StreamData.h +++ b/src/lib/datastreams/Tables/StreamData.h @@ -5,6 +5,7 @@ #include #include #include +#include #include // this file has all the classes that represent streaming tabular data // schema //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -134,8 +135,8 @@ class StreamTable { private: const StreamSchema &_schema; -}; // namespace bts::streams -// stream updates and subscription /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +}; +// stream updates and subscription //////////////////////////////////////////// class StreamUpdate { public: const StreamTable &complete_state; @@ -148,15 +149,37 @@ class StreamUpdate { : complete_state(complete_state_), deleted_ids(deleted_ids_), added_rows(added_rows_) {} }; + +class DirectSubsription {}; +class CloudSubscirption {}; +// template < +// typename T, +// typename = std::enable_if_t< +// std::is_same::value || +// std::is_same::value>> + +class StreamSubscription { + private: + std::variant subscription; + const size_t _sub_id; + + public: + StreamSubscription(const DirectSubsription &, size_t subscription_id_) + : _sub_id(subscription_id_) {} + StreamSubscription(const CloudSubscirption &, size_t subscription_id_) + : _sub_id(subscription_id_) {} + size_t sub_id() const { return _sub_id; } +}; + class IStreamSync { public: virtual void on_stream_update( - size_t sub_id, const StreamUpdate &stream_update) = 0; + const StreamSubscription &, const StreamUpdate &stream_update) = 0; }; + class StreamSource { public: - void subscribe_stream_expression( - std::string &, size_t, bool, IStreamSync &) {} - void subscribe_cloud_stream(std::string &, size_t, IStreamSync &) {} + void subscribe_stream_expression(const StreamSubscription &, IStreamSync &) { + } }; -} \ No newline at end of file +} // namespace bts::streams \ No newline at end of file