This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core.cache import cache as default_cache | |
from rest_framework.throttling import BaseThrottle | |
from rest_framework.settings import api_settings | |
import logging | |
logger = logging.getLogger('throttle') | |
def parse_rate(rate): | |
""" | |
Given the request rate string, return a two tuple of: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import absolute_import | |
"""Celery beat scheduler backed by Redis. | |
The schedule will be saved as a pickled data in the key | |
'celery:beat:<filename>', where filename is the schedule filename | |
configured in celery | |
Prerequisite: | |
You are using Redis as your broker (BROKER_URL = 'redis://...') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Maps a request to a tenant using the first part of the hostname. | |
For example: | |
foo.example.com:8000 -> foo | |
bar.baz.example.com -> bar | |
This is a simple example; you should probably verify tenant names | |
are valid before returning them, since the returned tenant name will | |
be issued in a `USE` SQL query. | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Maps a request to a tenant using Redis. | |
Redis should store a map of hostname -> tenant name. The tenant name | |
is then used to form the database and cache names. | |
""" | |
from db_multitenant import mapper | |
from django.http import Http404 | |
import redis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Manually reset the volume of all drinks in a session. | |
# You should run this by hand in "kegbot-admin.py shell" | |
# Be sure to run "kegbot-admin.py kb_regen_stats" after doing so. | |
ML_PER_TICK = 1.0/2200 # change me | |
SESSION_ID = 123 # change me | |
# Should not need to edit past here. | |
from pykeg.core import models |