rippled
Loading...
Searching...
No Matches
ResourceManager.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or 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#ifndef RIPPLE_RESOURCE_MANAGER_H_INCLUDED
21#define RIPPLE_RESOURCE_MANAGER_H_INCLUDED
22
23#include <xrpl/beast/insight/Collector.h>
24#include <xrpl/beast/net/IPEndpoint.h>
25#include <xrpl/beast/utility/Journal.h>
26#include <xrpl/beast/utility/PropertyStream.h>
27#include <xrpl/json/json_value.h>
28#include <xrpl/resource/Consumer.h>
29#include <xrpl/resource/Gossip.h>
30#include <boost/utility/string_view.hpp>
31
32namespace ripple {
33namespace Resource {
34
37{
38protected:
39 Manager();
40
41public:
42 virtual ~Manager() = 0;
43
46 virtual Consumer
48 virtual Consumer
50 beast::IP::Endpoint const& address,
51 bool const proxy,
53
55 virtual Consumer
57
59 virtual Consumer
61
63 virtual Gossip
65
67 virtual Json::Value
68 getJson() = 0;
69 virtual Json::Value
70 getJson(int threshold) = 0;
71
75 virtual void
76 importConsumers(std::string const& origin, Gossip const& gossip) = 0;
77};
78
79//------------------------------------------------------------------------------
80
83 beast::insight::Collector::ptr const& collector,
84 beast::Journal journal);
85
86} // namespace Resource
87} // namespace ripple
88
89#endif
Represents a JSON value.
Definition: json_value.h:147
A version-independent IP address and port combination.
Definition: IPEndpoint.h:39
A generic endpoint for log messages.
Definition: Journal.h:59
Subclasses can be called to write to a stream and have children.
An endpoint that consumes resources.
Definition: Consumer.h:35
Tracks load and resource consumption.
virtual Consumer newInboundEndpoint(beast::IP::Endpoint const &address)=0
Create a new endpoint keyed by inbound IP address or the forwarded IP if proxied.
virtual Json::Value getJson()=0
Extract consumer information for reporting.
virtual Gossip exportConsumers()=0
Extract packaged consumer information for export.
virtual Consumer newInboundEndpoint(beast::IP::Endpoint const &address, bool const proxy, std::string_view forwardedFor)=0
virtual Consumer newUnlimitedEndpoint(beast::IP::Endpoint const &address)=0
Create a new unlimited endpoint keyed by forwarded IP.
virtual void importConsumers(std::string const &origin, Gossip const &gossip)=0
Import packaged consumer information.
virtual Json::Value getJson(int threshold)=0
virtual Consumer newOutboundEndpoint(beast::IP::Endpoint const &address)=0
Create a new endpoint keyed by outbound IP address and port.
std::unique_ptr< Manager > make_Manager(beast::insight::Collector::ptr const &collector, beast::Journal journal)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
std::string_view forwardedFor(http_request_type const &request)
Definition: Role.cpp:261
Data format for exchanging consumption information across peers.
Definition: Gossip.h:30