Page Speed Optimization Libraries
1.13.35.1
|
#include "rate_controller.h"
Public Member Functions | |
RateController (int max_global_queue_size, int per_host_outgoing_request_threshold, int per_host_queued_request_threshold, ThreadSystem *thread_system, Statistics *statistics) | |
void | ShutDown () |
Makes any further fetches quick-fail. | |
bool | is_shut_down () const |
void | Fetch (UrlAsyncFetcher *fetcher, const GoogleString &url, MessageHandler *message_handler, AsyncFetch *fetch) |
Static Public Member Functions | |
static void | InitStats (Statistics *statistics) |
Initializes statistics variables associated with this class. | |
Static Public Attributes | |
static const char | kQueuedFetchCount [] |
static const char | kDroppedFetchCount [] |
static const char | kCurrentGlobalFetchQueueSize [] |
Friends | |
class | CustomFetch |
Controller which limits the number of outgoing fetches per domain. If the fetch is for a user-facing request, this sends the request out anyway and updates the count for number of outgoing fetches. For non-user facing requests, this checks that the number of outgoing fetches for this domain is less than the limit. If less than the limit, it sends the fetch out and updates the count. If greater than the per-domain limit, and if the global queue size is within the limit, it queues the request up. However, if the global queue size is above the limit, it drops the request. If a request is dropped, the response will have HttpAttributes::kXPsaLoadShed set on the response headers.
Note: this requires working statistics to work.
void net_instaweb::RateController::Fetch | ( | UrlAsyncFetcher * | fetcher, |
const GoogleString & | url, | ||
MessageHandler * | message_handler, | ||
AsyncFetch * | fetch | ||
) |
Applies our shaping policies, and either (eventually) asks fetcher to fetch the given URL or drops it.