-
-
Save dbalatero/176469 to your computer and use it in GitHub Desktop.
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
hydra = Typhoeus::Hydra.new(20) # number is the size of the easy object pool | |
user_request = User.find_request(1) # where 1 is the id of the user | |
user_request.on_complete do | |
@user = User.parse(user_request.response.body) | |
comment_requests = @user.comment_ids.map {|id| Comment.find_request(id)} | |
comment_requests.each do |comment_request| | |
comment_request.on_complete do | |
@user.comments << Comment.parse(comment_request.response.body) | |
end | |
hydra.queue << comment_request | |
end | |
end | |
hydra.queue << user_request | |
hydra.run! | |
# now we have a user object with all the comments |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment