Skip to content

Instantly share code, notes, and snippets.

@phobeo
Created April 15, 2011 16:53
Show Gist options
  • Save phobeo/922023 to your computer and use it in GitHub Desktop.
Save phobeo/922023 to your computer and use it in GitHub Desktop.
queues sample
class ProcessTimeline
def perform(tweet, user)
log "received #{tweet.id} for user #{user}"
# if tweet.id was not stored before, store tweet in all_tweets_for process collection
# store pair [tweet.id, user.id] in tweets_for_user collection
end
end
class ProcessTweet
def perform(tweet)
log "processing tweet #{tweet.id}
# do tweet analysis
end
end
# Log should look like:
received xxxxx for user ernestojimenez
received xxxxx for user phobeo
processing tweet xxxxx
# or it may look like
received xxxxx for user ernestojimenez
processing tweet xxxxx
received xxxxx for user phobeo
# or also
received xxxxx for user phobeo
processing tweet xxxxx
received xxxxx for user ernestojimenez
# but it should always process just one time, no?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment