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 "etlng/ETLServiceInterface.hpp"
26#include "feed/SubscriptionManagerInterface.hpp"
27#include "rpc/common/AnyHandler.hpp"
28#include "rpc/common/HandlerProvider.hpp"
29#include "rpc/common/Types.hpp"
30#include "util/log/Logger.hpp"
31
32#include <memory>
33#include <optional>
34#include <string>
35#include <unordered_map>
36#include <unordered_set>
37
38namespace rpc {
39class Counters;
40} // namespace rpc
41
42namespace rpc::impl {
43
45 struct Handler {
46 AnyHandler handler;
47 bool isClioOnly = false;
48 };
49
50 std::unordered_map<std::string, Handler> handlerMap_;
51
52public:
55 std::shared_ptr<BackendInterface> const& backend,
56 std::shared_ptr<feed::SubscriptionManagerInterface> const& subscriptionManager,
57 std::shared_ptr<etlng::LoadBalancerInterface> const& balancer,
58 std::shared_ptr<etlng::ETLServiceInterface const> const& etl,
59 std::shared_ptr<data::AmendmentCenterInterface const> const& amendmentCenter,
60 Counters const& counters
61 );
62
63 bool
64 contains(std::string const& command) const override;
65
66 std::optional<AnyHandler>
67 getHandler(std::string const& command) const override;
68
69 bool
70 isClioOnly(std::string const& command) const override;
71
72 std::unordered_set<std::string>
73 handlerNames() const;
74};
75
76} // 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:44
std::optional< AnyHandler > getHandler(std::string const &command) const override
Get the handler for a given method.
Definition HandlerProvider.cpp:129
bool contains(std::string const &command) const override
Check if the provider contains a handler for a given method.
Definition HandlerProvider.cpp:123
bool isClioOnly(std::string const &command) const override
Check if a given method is Clio-only.
Definition HandlerProvider.cpp:138
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:39
This namespace contains all the RPC logic and handlers.
Definition AMMHelpers.cpp:37