Aktualizr
C++ SOTA Client
|
Control the rate of outgoing requests. More...
#include <rate_controller.h>
Public Types | |
using | clock = std::chrono::steady_clock |
Public Member Functions | |
RateController (int concurrency_cap=30) | |
RateController (const RateController &)=delete | |
RateController | operator= (const RateController &)=delete |
void | RequestCompleted (clock::time_point start_time, clock::time_point end_time, bool succeeded) |
int | MaxConcurrency () const |
clock::duration | GetSleepTime () const |
bool | ServerHasFailed () const |
Control the rate of outgoing requests.
This receives signals from the network layer when a request finishes of the form (start time, end time, success). It generates controls for the network layer in the form of: MaxConcurrency - The current estimate of the number of parallel requests that can be opened Sleep() - The number of seconds to sleep before sending the next request. 0.0 if MaxConcurrency is > 1 Failed() - A boolean indicating that the server is broken, and to report an error up to the user. The congestion control is loosely based on the original TCP AIMD scheme. Better performance might be available by Stealing ideas from the later TCP conjection control algorithms
Definition at line 16 of file rate_controller.h.