-
Notifications
You must be signed in to change notification settings - Fork 45
Open
Description
Hello,
I currently migrate my imlpementation of pyrateLimiter from v3 to v4. I use pyrate limiter on celery worker that are distributed amongst various hosts and this make time.monotonic() (the default) unfit. In the v3 I was using a custom Redis clock (the redis DB is not distributed) :
class RedisClock(AbstractClock):
def now(self) -> int:
unix_time, microseconds = injector.get(redis.Redis).time() # injector.get(redis.Redis) return a redis client
milliseconds: int = (unix_time * 1000) + (microseconds // 1000)
return millisecondsAnd then to create the Limiter :
bucket = RedisBucket.init(
rates=[...],
redis=injector.get(redis.Redis),
bucket_key=bucket_name,
)
return Limiter(bucket, clock=RedisClock())How can I do in the v4 to define my clock ? Should I create a new implementation of the redis bucket ? Is it possible to get an exemple ? Also I saw in the code for the nox function of the redis bucket a TODO to use a Redis time source via a Lua script. Do you know when this will be available ? I think this will fix my issue.
Thanks for your reply
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels