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
37namespace rpc {
38class Counters;
39} // namespace rpc
40
41namespace rpc::impl {
42
44 struct Handler {
45 AnyHandler handler;
46 bool isClioOnly = false;
47 };
48
49 std::unordered_map<std::string, Handler> handlerMap_;
50
51public:
54 std::shared_ptr<BackendInterface> const& backend,
55 std::shared_ptr<feed::SubscriptionManagerInterface> const& subscriptionManager,
56 std::shared_ptr<etlng::LoadBalancerInterface> const& balancer,
57 std::shared_ptr<etlng::ETLServiceInterface const> const& etl,
58 std::shared_ptr<data::AmendmentCenterInterface const> const& amendmentCenter,
59 Counters const& counters
60 );
61
62 bool
63 contains(std::string const& command) const override;
64
65 std::optional<AnyHandler>
66 getHandler(std::string const& command) const override;
67
68 bool
69 isClioOnly(std::string const& command) const override;
70};
71
72} // 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:43
std::optional< AnyHandler > getHandler(std::string const &command) const override
Get the handler for a given method.
Definition HandlerProvider.cpp:128
bool contains(std::string const &command) const override
Check if the provider contains a handler for a given method.
Definition HandlerProvider.cpp:122
bool isClioOnly(std::string const &command) const override
Check if a given method is Clio-only.
Definition HandlerProvider.cpp:137
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:37
This namespace contains all the RPC logic and handlers.
Definition AMMHelpers.cpp:37