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
31#include <boost/utility/string_view.hpp>
32
33namespace ripple {
34namespace Resource {
35
38{
39protected:
40 Manager();
41
42public:
43 virtual ~Manager() = 0;
44
47 virtual Consumer
49 virtual Consumer
51 beast::IP::Endpoint const& address,
52 bool const proxy,
54
56 virtual Consumer
58
60 virtual Consumer
62
64 virtual Gossip
66
68 virtual Json::Value
69 getJson() = 0;
70 virtual Json::Value
71 getJson(int threshold) = 0;
72
76 virtual void
77 importConsumers(std::string const& origin, Gossip const& gossip) = 0;
78};
79
80//------------------------------------------------------------------------------
81
84 beast::insight::Collector::ptr const& collector,
85 beast::Journal journal);
86
87} // namespace Resource
88} // namespace ripple
89
90#endif
Represents a JSON value.
Definition json_value.h:149
A version-independent IP address and port combination.
Definition IPEndpoint.h:38
A generic endpoint for log messages.
Definition Journal.h:60
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:25
std::string_view forwardedFor(http_request_type const &request)
Definition Role.cpp:262
Data format for exchanging consumption information across peers.
Definition Gossip.h:32