Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
HandlerProvider.hpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of clio: https://github.com/XRPLF/clio
4 Copyright (c) 2023, the clio developers.
5
6 Permission to use, copy, modify, and distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#pragma once
21
22#include "data/AmendmentCenterInterface.hpp"
23#include "data/BackendInterface.hpp"
24#include "feed/SubscriptionManagerInterface.hpp"
25#include "rpc/common/AnyHandler.hpp"
26#include "rpc/common/HandlerProvider.hpp"
27#include "rpc/common/Types.hpp"
28#include "util/log/Logger.hpp"
29
30#include <memory>
31#include <optional>
32#include <string>
33#include <unordered_map>
34
35namespace etl {
36class ETLService;
37class LoadBalancer;
38} // namespace etl
39namespace rpc {
40class Counters;
41} // namespace rpc
42
43namespace rpc::impl {
44
46 struct Handler {
47 AnyHandler handler;
48 bool isClioOnly = false;
49 };
50
51 std::unordered_map<std::string, Handler> handlerMap_;
52
53public:
56 std::shared_ptr<BackendInterface> const& backend,
57 std::shared_ptr<feed::SubscriptionManagerInterface> const& subscriptionManager,
58 std::shared_ptr<etl::LoadBalancer> const& balancer,
59 std::shared_ptr<etl::ETLService const> const& etl,
60 std::shared_ptr<data::AmendmentCenterInterface const> const& amendmentCenter,
61 Counters const& counters
62 );
63
64 bool
65 contains(std::string const& command) const override;
66
67 std::optional<AnyHandler>
68 getHandler(std::string const& command) const override;
69
70 bool
71 isClioOnly(std::string const& command) const override;
72};
73
74} // namespace rpc::impl
A type-erased Handler that can contain any (NextGen) RPC handler class.
Definition AnyHandler.hpp:39
Holds information about successful, failed, forwarded, etc. RPC handler calls.
Definition Counters.hpp:39
Interface for the provider of RPC handlers.
Definition HandlerProvider.hpp:32
Definition HandlerProvider.hpp:45
std::optional< AnyHandler > getHandler(std::string const &command) const override
Get the handler for a given method.
Definition HandlerProvider.cpp:127
bool contains(std::string const &command) const override
Check if the provider contains a handler for a given method.
Definition HandlerProvider.cpp:121
bool isClioOnly(std::string const &command) const override
Check if a given method is Clio-only.
Definition HandlerProvider.cpp:136
All the config data will be stored and extracted from this class.
Definition ConfigDefinition.hpp:54
This namespace contains everything to do with the ETL and ETL sources.
Definition CacheLoader.hpp:36
This namespace contains all the RPC logic and handlers.
Definition AMMHelpers.cpp:36