[tor-commits] [ooni-probe/master] Outline the rate limiting abstract class (#7852)
isis at torproject.org
isis at torproject.org
Sun Mar 10 01:57:01 UTC 2013
commit 6f5da8e07d7cbc357ba4a15f7a65d3cf57925a11
Author: Arturo Filastò <art at fuffa.org>
Date: Thu Jan 10 16:20:29 2013 +0100
Outline the rate limiting abstract class (#7852)
Classes that impose constraints on timeouts and issue rate go here.
---
ooni/ratelimiting.py | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 68 insertions(+), 0 deletions(-)
diff --git a/ooni/ratelimiting.py b/ooni/ratelimiting.py
new file mode 100644
index 0000000..986cf82
--- /dev/null
+++ b/ooni/ratelimiting.py
@@ -0,0 +1,68 @@
+class RateLimiter(object):
+ """
+ The abstract class that imposes limits over how measurements are scheduled,
+ how retries are handled and when we should be giving up on a certain
+ measurement.
+ """
+ @property
+ def timeout(self):
+ """
+ After what timeout a certain test should be considered to have failed
+ and attempt a retry if the maximum retry has not been reached.
+ """
+ raise NotImplemented
+
+ @property
+ def maxTimeout(self):
+ """
+ This is the maximum value that timeout can reach.
+ """
+ raise NotImplemented
+
+ @property
+ def concurrency(self):
+ """
+ How many concurrent requests should happen at the same time.
+ """
+ raise NotImplemented
+
+ def timedOut(self, measurement):
+ raise NotImplemented
+
+ def completed(self, measurement):
+ raise NotImplemented
+
+ def failed(self, measurement):
+ raise NotImplemented
+
+class StaticRateLimiter(RateLimiter):
+ """
+ This is a static ratelimiter that returns constant values.
+ """
+ @property
+ def timeout(self):
+ return 10
+
+ @property
+ def maxTimeout(self):
+ return 5 * 60
+
+ @property
+ def concurrency(self):
+ return 10
+
+ def timedOut(self, measurement):
+ pass
+
+ def completed(self, measurement):
+ pass
+
+ def failed(self, measurement, failure):
+ pass
+
+class TimeoutRateLimiter(RateLimiter):
+ pass
+
+class BandwidthRateLimiter(RateLimiter):
+ pass
+
More information about the tor-commits
mailing list