gufo.snmp.policer¶
Policer abstract base class and the implementations.
BasePolicer
¶
Bases: ABC
Base query policer.
Query policer limits the rate of outgoing GET/GETNEXT/GETBULK queries up to the desired rate.
This is abstract class, the real implemetation must be defined in subclasses.
The instances of the subclasses can be used as SnmpSession.policer parameters.
get_timeout(ts)
abstractmethod
¶
Get sleep timeout.
Calculate next sleep timeout and adjust the internal state. Separate function for the testing purposes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ts
|
int
|
Result of perf_counter_ns() |
required |
Returns:
Type | Description |
---|---|
Optional[int]
|
|
Optional[int]
|
|
wait()
async
¶
Apply policy.
Waits until the sending of the next request will be possible according to the policy.
May be interrupted by TimeoutError.
wait_sync()
¶
Apply policy (Synchronous version).
Waits until the sending of the next request will be possible according to the policy.
May be interrupted by TimeoutError.
RPSPolicer
¶
Bases: BasePolicer
Requests per seconds policer.
Aligns queries up to rps
requests
per seconds and tries to arrange queries
to the equal intervals.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
rps
|
float
|
Requests per second rate. |
required |
get_timeout(ts)
¶
Get sleep timeout.
Calculate next sleep timeout and adjust the internal state. Separate function for the testing purposes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ts
|
int
|
Result of perf_counter_ns() |
required |
Returns:
Type | Description |
---|---|
Optional[int]
|
|
Optional[int]
|
|