Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
HandlerProvider.hpp
1#pragma once
2
3#include "data/AmendmentCenterInterface.hpp"
4#include "data/BackendInterface.hpp"
5#include "etl/ETLServiceInterface.hpp"
7#include "feed/SubscriptionManagerInterface.hpp"
8#include "rpc/common/AnyHandler.hpp"
9#include "rpc/common/HandlerProvider.hpp"
10#include "rpc/common/Types.hpp"
11#include "util/log/Logger.hpp"
12
13#include <memory>
14#include <optional>
15#include <string>
16#include <unordered_map>
17#include <unordered_set>
18
19namespace rpc {
20class Counters;
21} // namespace rpc
22
23namespace rpc::impl {
24
25class ProductionHandlerProvider final : public HandlerProvider {
26 struct Handler {
27 AnyHandler handler;
28 bool isClioOnly = false;
29 };
30
31 std::unordered_map<std::string, Handler> handlerMap_;
32
33public:
34 ProductionHandlerProvider(
36 std::shared_ptr<BackendInterface> const& backend,
37 std::shared_ptr<feed::SubscriptionManagerInterface> const& subscriptionManager,
38 std::shared_ptr<etl::LoadBalancerInterface> const& balancer,
39 std::shared_ptr<etl::ETLServiceInterface const> const& etl,
40 std::shared_ptr<data::AmendmentCenterInterface const> const& amendmentCenter,
41 Counters const& counters
42 );
43
44 bool
45 contains(std::string const& command) const override;
46
47 std::optional<AnyHandler>
48 getHandler(std::string const& command) const override;
49
50 bool
51 isClioOnly(std::string const& command) const override;
52
53 std::unordered_set<std::string>
54 handlerNames() const;
55};
56
57} // namespace rpc::impl
A type-erased Handler that can contain any (NextGen) RPC handler class.
Definition AnyHandler.hpp:20
Holds information about successful, failed, forwarded, etc. RPC handler calls.
Definition Counters.hpp:22
Interface for the provider of RPC handlers.
Definition HandlerProvider.hpp:13
std::optional< AnyHandler > getHandler(std::string const &command) const override
Get the handler for a given method.
Definition HandlerProvider.cpp:124
bool contains(std::string const &command) const override
Check if the provider contains a handler for a given method.
Definition HandlerProvider.cpp:118
bool isClioOnly(std::string const &command) const override
Check if a given method is Clio-only.
Definition HandlerProvider.cpp:133
All the config data will be stored and extracted from this class.
Definition ConfigDefinition.hpp:31
This namespace contains all the RPC logic and handlers.
Definition AMMHelpers.cpp:18