Clio
develop
The XRP Ledger API server.
Theme:
Default
Round
Robot
Toggle main menu visibility
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
18
namespace
feed::impl {
19
23
class
SingleFeedBase
{
24
util::async::AnyStrand
strand_;
25
std::reference_wrapper<util::prometheus::GaugeInt> subCount_;
26
TrackableSignal<Subscriber, std::shared_ptr<std::string>
const
&> signal_;
27
util::Logger
logger_{
"Subscriptions"
};
28
std::string name_;
29
30
public
:
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
65
private
:
66
void
67
unsubInternal(
SubscriberPtr
subscriber);
68
};
69
}
// namespace feed::impl
feed::impl::SingleFeedBase::unsub
void unsub(SubscriberSharedPtr const &subscriber)
Unsubscribe the feed.
Definition
SingleFeedBase.cpp:45
feed::impl::SingleFeedBase::count
std::uint64_t count() const
Get the count of subscribers.
Definition
SingleFeedBase.cpp:60
feed::impl::SingleFeedBase::pub
void pub(std::string msg)
Publishes the feed in strand.
Definition
SingleFeedBase.cpp:51
feed::impl::SingleFeedBase::SingleFeedBase
SingleFeedBase(util::async::AnyExecutionContext &executionCtx, std::string const &name)
Construct a new Single Feed Base object.
Definition
SingleFeedBase.cpp:16
feed::impl::SingleFeedBase::sub
void sub(SubscriberSharedPtr const &subscriber)
Subscribe the feed.
Definition
SingleFeedBase.cpp:25
feed::impl::TrackableSignal
A thread-safe class to manage a signal and its tracking connections.
Definition
TrackableSignal.hpp:26
util::Logger
A simple thread-safe logger for the channel specified in the constructor.
Definition
Logger.hpp:110
util::async::AnyExecutionContext
A type-erased execution context.
Definition
AnyExecutionContext.hpp:23
util::async::AnyStrand
A type-erased execution context.
Definition
AnyStrand.hpp:22
feed::SubscriberSharedPtr
std::shared_ptr< Subscriber > SubscriberSharedPtr
Shared ownership pointer to a subscriber.
Definition
Types.hpp:22
feed::SubscriberPtr
Subscriber * SubscriberPtr
Non-owning pointer to a subscriber.
Definition
Types.hpp:17
src
feed
impl
SingleFeedBase.hpp
Generated by
1.17.0