Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
fastlane: Separate votes on some links and their comments.
Browse files Browse the repository at this point in the history
If a specific link has ridiculous traffic, we can inform the
apps (via ZK live config) that votes on it should be sent to a
separate, dedicated, queue to avoid overwhelming the rest of the
system.
  • Loading branch information
spladug committed Aug 30, 2012
1 parent 5ba0618 commit c337280
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions r2/example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,8 @@ beaker.session_secret = somesecret
[live_config]
# make frontpage 100% dart
frontpage_dart = false
# links that get their own infrastructure (comma-delimited list of id36s)
fastlane_links =
# spotlight links for subreddit discovery
sr_discovery_links =
# probability of the subreddit suggester showing up in the spotlight box
Expand Down
1 change: 1 addition & 0 deletions r2/r2/lib/app_globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ class Globals(object):
],
ConfigValue.tuple: [
'sr_discovery_links',
'fastlane_links',
],
}

Expand Down
12 changes: 10 additions & 2 deletions r2/r2/lib/db/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -1284,6 +1284,7 @@ def _run_commentstree(msgs, chan):

vote_link_q = 'vote_link_q'
vote_comment_q = 'vote_comment_q'
vote_fastlane_q = 'vote_fastlane_q'

def queue_vote(user, thing, dir, ip, organic = False,
cheater = False, store = True):
Expand All @@ -1294,9 +1295,16 @@ def queue_vote(user, thing, dir, ip, organic = False,
if store:
if g.amqp_host:
if isinstance(thing, Link):
qname = vote_link_q
if thing._id36 in g.live_config["fastlane_links"]:
qname = vote_fastlane_q
else:
qname = vote_link_q

elif isinstance(thing, Comment):
qname = vote_comment_q
if utils.to36(thing.link_id) in g.live_config["fastlane_links"]:
qname = vote_fastlane_q
else:
qname = vote_comment_q
else:
log.warning("%s tried to vote on %r. that's not a link or comment!",
user, thing)
Expand Down
1 change: 1 addition & 0 deletions r2/r2/lib/queues.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def queues(self):
self._q('register_vote_q', self_refer=True)
self._q('vote_link_q', self_refer=True)
self._q('vote_comment_q', self_refer=True)
self._q('vote_fastlane_q', self_refer=True)
self._q('log_q', self_refer=True)
self._q('usage_q', self_refer=True, durable=False)

Expand Down

0 comments on commit c337280

Please sign in to comment.