| #ifndef THIRD_PARTY_MILOTIC_EXTERNAL_CC_HFT_SUBSCRIPTION_MANAGER_H_ |
| #define THIRD_PARTY_MILOTIC_EXTERNAL_CC_HFT_SUBSCRIPTION_MANAGER_H_ |
| |
| #include <memory> |
| |
| #include "absl/functional/any_invocable.h" |
| #include "tlbmc/adapter/data_source.h" |
| #include "tlbmc/subscription/store.h" |
| #include "tlbmc/types/payload.proto.h" |
| #include "tlbmc/types/subscription_params.proto.h" |
| #include "tlbmc/scheduler/scheduler.h" |
| |
| namespace milotic_hft { |
| |
| class SubscriptionManager { |
| public: |
| // A handle to a subscription that can be used to cancel the subscription. |
| class SubscriptionHandle { |
| public: |
| ~SubscriptionHandle() { subscription_->Cancel(); } |
| |
| private: |
| Subscription* subscription_; |
| }; |
| |
| virtual ~SubscriptionManager() = default; |
| |
| // Adds a new subscription to the manager. |
| // `on_data_callback` will be called when new data is available to be exported |
| // to the subscriber. |
| virtual void AddSubscription( |
| const SubscriptionParams& params, |
| absl::AnyInvocable<void(Payload&&)> |
| on_data_callback) = 0; |
| |
| private: |
| // An adapter to the data source. |
| std::unique_ptr<DataSource> data_source_; |
| std::unique_ptr<SubscriptionStore> subscription_store_; |
| std::unique_ptr<milotic_tlbmc::TaskScheduler> task_scheduler_; |
| }; |
| |
| } // namespace milotic_hft |
| |
| #endif // THIRD_PARTY_MILOTIC_EXTERNAL_CC_HFT_SUBSCRIPTION_MANAGER_H_ |