comparison roundup/rate_limit.py @ 5722:2f116ba7e7cf

Rename Store class in rate_limit.py to Gcra. The name Store makes no sense since the class implements a Gcra, I'll call it Gcra....
author John Rouillard <rouilj@ieee.org>
date Fri, 17 May 2019 19:45:15 -0400
parents cad18de2b988
children e225f403cc35
comparison
equal deleted inserted replaced
5721:abb9fdb02228 5722:2f116ba7e7cf
14 @property 14 @property
15 def inverse(self): 15 def inverse(self):
16 return self.period.total_seconds() / self.count 16 return self.period.total_seconds() / self.count
17 17
18 18
19 class Store: 19 class Gcra:
20 20
21 memory = {} 21 memory = {}
22 22
23 def get_tat(self, key): 23 def get_tat(self, key):
24 # This should return a previous tat for the key or the current time. 24 # This should return a previous tat for the key or the current time.
80 ret = {} 80 ret = {}
81 tat = self.get_tat(key) 81 tat = self.get_tat(key)
82 82
83 # static defined headers according to limit 83 # static defined headers according to limit
84 ret['X-RateLimit-Limit'] = limit.count 84 ret['X-RateLimit-Limit'] = limit.count
85 ret['X-RateLimit-Limit-Period'] = limit.period.total_seconds() 85 ret['X-RateLimit-Limit-Period'] = int(limit.period.total_seconds())
86 86
87 # status of current limit as of now 87 # status of current limit as of now
88 now = datetime.utcnow() 88 now = datetime.utcnow()
89 89
90 ret['X-RateLimit-Remaining'] = min(int( 90 ret['X-RateLimit-Remaining'] = min(int(

Roundup Issue Tracker: http://roundup-tracker.org/