Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
ForwardingSource.hpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of clio: https://github.com/XRPLF/clio
4 Copyright (c) 2024, 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 "rpc/Errors.hpp"
23#include "util/log/Logger.hpp"
24#include "util/requests/WsConnection.hpp"
25
26#include <boost/asio/spawn.hpp>
27#include <boost/json/object.hpp>
28
29#include <chrono>
30#include <expected>
31#include <optional>
32#include <string>
33#include <string_view>
34
35namespace etl::impl {
36
38 util::Logger log_;
39 util::requests::WsConnectionBuilder connectionBuilder_;
40 std::chrono::steady_clock::duration forwardingTimeout_;
41
42 static constexpr std::chrono::seconds kCONNECTION_TIMEOUT{3};
43
44public:
46 std::string ip,
47 std::string wsPort,
48 std::chrono::steady_clock::duration forwardingTimeout,
49 std::chrono::steady_clock::duration connTimeout = ForwardingSource::kCONNECTION_TIMEOUT
50 );
51
61 std::expected<boost::json::object, rpc::ClioError>
63 boost::json::object const& request,
64 std::optional<std::string> const& forwardToRippledClientIp,
65 std::string_view xUserValue,
66 boost::asio::yield_context yield
67 ) const;
68};
69
70} // namespace etl::impl
Definition ForwardingSource.hpp:37
std::expected< boost::json::object, rpc::ClioError > forwardToRippled(boost::json::object const &request, std::optional< std::string > const &forwardToRippledClientIp, std::string_view xUserValue, boost::asio::yield_context yield) const
Forward a request to rippled.
Definition ForwardingSource.cpp:60
A simple thread-safe logger for the channel specified in the constructor.
Definition Logger.hpp:110
Builder for WebSocket connections.
Definition WsConnection.hpp:97