Go to the SVN repository for this file.
1 #ifndef CORELIB___REQUEST_CONTROL__HPP 2 #define CORELIB___REQUEST_CONTROL__HPP 64eMinTimeBetweenRequests
130(
unsigned intnum_requests_allowed,
133EThrottleAction throttle_action =
eDefault,
134EThrottleMode throttle_mode = eContinuous);
157 voidReset(
unsigned intnum_requests_allowed,
160EThrottleAction throttle_action =
eDefault,
161EThrottleMode throttle_mode = eContinuous);
175 boolApprove(EThrottleAction action =
eDefault);
197 static voidSleep(
CTimeSpansleep_time);
202 void Lock() { Approve(eSleep); }
206 bool IsEnabled(
void)
const{
returnm_NumRequestsAllowed != kNoLimit; }
215 voidx_CleanTimeLine(
TTimenow);
CRequestRateControlException â.
virtual const char * GetErrCodeString(void) const override
Translate from the error code value to its string representation.
EErrCode
Error types that an application can generate.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
unsigned int m_NumRequests
Num requests per period.
EThrottleAction
What to do if exceeded the rate limits.
bool IsEnabled(void) const
Check if throttling is enabled.
EThrottleMode
Throttle mode.
TTime m_MinTimeBetweenRequests
EThrottleAction m_ThrottleAction
CStopWatch m_StopWatch
Stopwatch to measure elapsed time.
CTimeSpan ApproveTime(void)
Get a time span in which request can be approved.
unsigned int m_NumRequestsAllowed
TTimeLine m_TimeLine
Vector of times of approvals.
void Lock()
Lock/unlock functions for use by generic RAII guard CGuard.
bool Approve(EThrottleAction action=eDefault)
Approve a request.
NCBI_EXCEPTION_DEFAULT(CRequestRateControlException, CCoreException)
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.
@ eErrCode
Return immediately with err code == FALSE.
@ eContinuous
Uses float time frame to check number of requests.
@ eNumRequestsPerPeriod
Number of requests per period exceeded;.
@ eNumRequestsMax
Maximum number of requests exceeded;.
#define NCBI_XNCBI_EXPORT
Defines: CTimeFormat - storage class for time format.
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