num_requests_allowed,
54 Reset(num_requests_allowed, per_period, min_time_between_requests,
55throttle_action, throttle_mode);
60 unsigned intnum_requests_allowed,
117 "CRequestRateControl::Approve(): " 118 "Maximum number of requests exceeded" 146 TTimex_sleeptime = 0;
149 if( !empty_period ) {
166eNumRequestsPerPeriod,
167 "CRequestRateControl::Approve(): " 168 "Maximum number of requests per period exceeded" 183 if(
st> x_sleeptime ) {
193eMinTimeBetweenRequests,
194 "CRequestRateControl::Approve(): The time " 195 "between two consecutive requests is too short" 204 if( x_sleeptime > 0 ) {
219 if( !empty_period ) {
254TTimeLine::iterator current;
CRequestRateControlException â.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
TErrCode GetErrCode(void) const
virtual const char * GetErrCodeString(void) const
Get error code interpreted as text.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
double Restart(void)
Return time elapsed since first Start() or last Restart() call (in seconds).
double Elapsed(void) const
Return time elapsed since first Start() or last Restart() call (in seconds).
long GetNanoSecondsAfterSecond(void) const
Get number of nanoseconds.
double GetAsDouble(void) const
Return time span as number of seconds.
const long kMicroSecondsPerSecond
Number of microseconds in one second.
long GetCompleteSeconds(void) const
Get number of complete seconds.
unsigned int m_NumRequests
Num requests per period.
void x_CleanTimeLine(TTime now)
Remove from the list of approved requests all expared items.
static void Sleep(CTimeSpan sleep_time)
Sleep for CTimeSpan.
EThrottleAction
What to do if exceeded the rate limits.
EThrottleMode
Throttle mode.
TTime m_MinTimeBetweenRequests
EThrottleAction m_ThrottleAction
CRequestRateControl(unsigned int num_requests_allowed, CTimeSpan per_period=CTimeSpan(1, 0), CTimeSpan min_time_between_requests=CTimeSpan(0, 0), EThrottleAction throttle_action=eDefault, EThrottleMode throttle_mode=eContinuous)
Constructor.
CStopWatch m_StopWatch
Stopwatch to measure elapsed time.
unsigned int m_NumRequestsAllowed
TTimeLine m_TimeLine
Vector of times of approvals.
static const unsigned int kNoLimit
Special value for maximum number of allowed requests per period.
virtual const char * GetErrCodeString(void) const override
Translate from the error code value to its string representation.
void Reset(unsigned int num_requests_allowed, CTimeSpan per_period=CTimeSpan(1, 0), CTimeSpan min_time_between_requests=CTimeSpan(0, 0), EThrottleAction throttle_action=eDefault, EThrottleMode throttle_mode=eContinuous)
Set new restriction for throttling mechanism.
bool x_Approve(EThrottleAction action, CTimeSpan *sleeptime)
TTime m_LastApproved
Last approve time.
@ eSleep
Sleep till the rate requirements are met & return.
@ eException
Throw an exception.
@ eDefault
in c-tor â eSleep; in Approve() â value set in c-tor
@ eErrCode
Return immediately with err code == FALSE.
@ eContinuous
Uses float time frame to check number of requests.
@ eDiscrete
Uses fixed time frame to check number of requests.
@ eMinTimeBetweenRequests
The time between two consecutive requests is too short;.
@ eNumRequestsPerPeriod
Number of requests per period exceeded;.
@ eNumRequestsMax
Maximum number of requests exceeded;.
unsigned int
A callback function used to compare two keys in a database.
void SleepMicroSec(unsigned long mc_sec, EInterruptOnSignal onsignal=eRestartOnSignal)
void SleepSec(unsigned long sec, EInterruptOnSignal onsignal=eRestartOnSignal)
Sleep.
static SLJIT_INLINE sljit_ins ms(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
static SLJIT_INLINE sljit_ins st(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4