-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A subscription model #34
Comments
Can use reddis to implement it from scratch[1], [2] or use a third party library. Read More: nordicapis # docker run -p 6379:6379 --name redis_server redis:4-alpine
import redis
r = redis.StrictRedis(host='localhost', port=6379, decode_responses=True, password="")
print('Ping:', r.ping())
print(r)
print('setting:', r.set("key", "value"))
print('getting:', r.get("key"))
import time
username = 'user1'
WINDOW_LENGTH = 2 # in Seconds
for _ in range(3):
cur_time = time.time()
r.zadd(username, {cur_time: cur_time})
time.sleep(1) # Sleep for 1 Second
p = r.pipeline()
p.zremrangebyscore(username, 0, time.time() - WINDOW_LENGTH)
cur_time = time.time()
p.zadd(username, {cur_time: cur_time})
p.expire(username, WINDOW_LENGTH)
p.execute()
print(r.zrange(username, 0, -1))
|
Read about saga pattern and 2 phase commit Another helpful stackoverflow thread. |
The subscription based Rate Limiting should be developed as a separate and completely independent identity, which is easy to plug in into any existing product. Is should not be tightly coupled with existing product. A possible Architecture: Similarly Data Monitoring Service can also be separated out into an independent project. |
Flow for
|
Add a subscription model. An existing user can have one of the following subscription tiers:
The limit on the number of API calls by a user should be limited by the type of subscription they own.
The text was updated successfully, but these errors were encountered: