Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
SingleFeedBase.hpp
1#pragma once
2
3#include "feed/Types.hpp"
4#include "feed/impl/TrackableSignal.hpp"
5#include "util/async/AnyExecutionContext.hpp"
6#include "util/async/AnyStrand.hpp"
7#include "util/log/Logger.hpp"
8#include "util/prometheus/Gauge.hpp"
9
10#include <boost/asio/io_context.hpp>
11#include <boost/asio/strand.hpp>
12
13#include <cstdint>
14#include <functional>
15#include <memory>
16#include <string>
17
18namespace feed::impl {
19
25 std::reference_wrapper<util::prometheus::GaugeInt> subCount_;
27 util::Logger logger_{"Subscriptions"};
28 std::string name_;
29
30public:
36 SingleFeedBase(util::async::AnyExecutionContext& executionCtx, std::string const& name);
37
42 void
43 sub(SubscriberSharedPtr const& subscriber);
44
49 void
50 unsub(SubscriberSharedPtr const& subscriber);
51
56 void
57 pub(std::string msg);
58
62 std::uint64_t
63 count() const;
64
65private:
66 void
67 unsubInternal(SubscriberPtr subscriber);
68};
69} // namespace feed::impl
void unsub(SubscriberSharedPtr const &subscriber)
Unsubscribe the feed.
Definition SingleFeedBase.cpp:45
std::uint64_t count() const
Get the count of subscribers.
Definition SingleFeedBase.cpp:60
void pub(std::string msg)
Publishes the feed in strand.
Definition SingleFeedBase.cpp:51
SingleFeedBase(util::async::AnyExecutionContext &executionCtx, std::string const &name)
Construct a new Single Feed Base object.
Definition SingleFeedBase.cpp:16
void sub(SubscriberSharedPtr const &subscriber)
Subscribe the feed.
Definition SingleFeedBase.cpp:25
A thread-safe class to manage a signal and its tracking connections.
Definition TrackableSignal.hpp:26
A simple thread-safe logger for the channel specified in the constructor.
Definition Logger.hpp:78
A type-erased execution context.
Definition AnyExecutionContext.hpp:22
A type-erased execution context.
Definition AnyStrand.hpp:21