Skip to content

Commit

Permalink
Merge branch 'master' of github.com:seatgeek/sixpack
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Hudson committed Apr 2, 2013
2 parents 5f5bc08 + 3f1fd5a commit 3c57bc0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Next, create a Sixpack configuration. A configuration must be created for sixpac
redis_db: 15 # DB number in redis

full_response: True # Not In Use
disable_whiplash: True # Disable the whiplash/multi-armed bandit choice Algorithm
enable_whiplash: False # Disable the whiplash/multi-armed bandit choice Algorithm

# The regex to match for robots
robot_regex: $^|trivial|facebook|MetaURI|butterfly|google|amazon|goldfire|sleuth|xenu|msnbot|SiteUptime|Slurp|WordPress|ZIBB|ZyBorg|pingdom|bot|yahoo|slurp|java|fetch|spider|url|crawl|oneriot|abby|commentreader|twiceler
Expand Down
2 changes: 1 addition & 1 deletion config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ redis_prefix: sxp
redis_db: 15

full_response: True
disable_whiplash: True
enable_whiplash: True

robot_regex: $^|trivial|facebook|MetaURI|butterfly|google|amazon|goldfire|sleuth|xenu|msnbot|SiteUptime|Slurp|WordPress|ZIBB|ZyBorg|pingdom|bot|yahoo|slurp|java|fetch|spider|url|crawl|oneriot|abby|commentreader|twiceler
ignored_ip_addresses: []
Expand Down
9 changes: 3 additions & 6 deletions sixpack/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,11 @@ def existing_alternative(self, client):
return None

def choose_alternative(self, client=None):
if cfg.get('disable_whiplash'):
return self._random_choice()

if random.random() < self.random_sample:
return self._random_choice()
else:
if cfg.get('enable_whiplash') and random.random() >= self.random_sample:
return Alternative(self._whiplash(), self, self.redis)

return self._random_choice()

def _random_choice(self):
return random.choice(self.alternatives)

Expand Down

0 comments on commit 3c57bc0

Please sign in to comment.