ratelimiter

class naz.ratelimiter.BaseRateLimiter[source]

Bases: abc.ABC

This is the interface that must be implemented to satisfy naz’s rate limiting. User implementations should inherit this class and implement the limit methods with the type signatures shown.

It may be important to control the rate at which the client(naz) sends requests to an SMSC/server. naz lets you do this, by allowing you to specify a custom rate limiter.

abstract async limit()[source]

rate limit sending of messages to SMSC.

Return type

None

class naz.ratelimiter.SimpleRateLimiter(send_rate=100000.0, logger=None)[source]

Bases: naz.ratelimiter.BaseRateLimiter

This is an implementation of BaseRateLimiter.

It does rate limiting using a token bucket rate limiting algorithm

example usage:

rate_limiter = SimpleRateLimiter(send_rate=10)
await rate_limiter.limit()
send_messsages()
__init__(send_rate=100000.0, logger=None)[source]
Parameters

send_rate (float) – the maximum rate, in messages/second, at which naz can send messages to SMSC.

Return type

None

async limit()[source]

rate limit sending of messages to SMSC.

Return type

None