mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-26 22:55:53 +00:00
@@ -52,6 +52,9 @@
|
||||
*/
|
||||
namespace feed {
|
||||
|
||||
/**
|
||||
* @brief A subscription manager is responsible for managing the subscriptions and publishing the feeds
|
||||
*/
|
||||
class SubscriptionManager {
|
||||
std::reference_wrapper<boost::asio::io_context> ioContext_;
|
||||
std::shared_ptr<data::BackendInterface const> backend_;
|
||||
@@ -64,6 +67,12 @@ class SubscriptionManager {
|
||||
impl::ProposedTransactionFeed proposedTransactionFeed_;
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new Subscription Manager object
|
||||
*
|
||||
* @param ioContext The io context to use
|
||||
* @param backend The backend to use
|
||||
*/
|
||||
SubscriptionManager(
|
||||
boost::asio::io_context& ioContext,
|
||||
std::shared_ptr<data::BackendInterface const> const& backend
|
||||
@@ -141,7 +150,9 @@ public:
|
||||
|
||||
/**
|
||||
* @brief Subscribe to the ledger feed.
|
||||
* @param subscriber
|
||||
* @param yield The coroutine context
|
||||
* @param subscriber The subscriber to the ledger feed
|
||||
* @return The ledger feed
|
||||
*/
|
||||
boost::json::object
|
||||
subLedger(boost::asio::yield_context yield, SubscriberSharedPtr const& subscriber);
|
||||
@@ -236,7 +247,8 @@ public:
|
||||
|
||||
/**
|
||||
* @brief Unsubscribe to the transactions feed for particular account.
|
||||
* @param subscriber
|
||||
* @param account The account to stop watching
|
||||
* @param subscriber The subscriber to unsubscribe
|
||||
*/
|
||||
void
|
||||
unsubAccount(ripple::AccountID const& account, SubscriberSharedPtr const& subscriber);
|
||||
@@ -268,6 +280,8 @@ public:
|
||||
|
||||
/**
|
||||
* @brief Get the number of subscribers.
|
||||
*
|
||||
* @return The report of the number of subscribers
|
||||
*/
|
||||
boost::json::object
|
||||
report() const
|
||||
@@ -299,6 +313,12 @@ class SubscriptionManagerRunner {
|
||||
std::vector<std::thread> workers_;
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new Subscription Manager Runner object
|
||||
*
|
||||
* @param config The configuration
|
||||
* @param backend The backend to use
|
||||
*/
|
||||
SubscriptionManagerRunner(util::Config const& config, std::shared_ptr<data::BackendInterface> const& backend)
|
||||
: subscriptionManager_(std::make_shared<SubscriptionManager>(ioContext_, backend))
|
||||
{
|
||||
@@ -309,6 +329,11 @@ public:
|
||||
workers_.emplace_back([&] { ioContext_.run(); });
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the subscription manager
|
||||
*
|
||||
* @return The subscription manager
|
||||
*/
|
||||
std::shared_ptr<SubscriptionManager>
|
||||
getManager()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user