Created
April 28, 2012 15:36
-
-
Save richievos/2519851 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# when we can, we do something like this: | |
in_parallel do |hydra| | |
hydra.push client.get_x(:user_id => 1, :id => 2) do |response| | |
@x = response.processed_response if response.success? | |
end | |
hydra.push client.get_y(:user_id => 1, :id => 3) do |response| | |
@y = response.processed_response if response.success? | |
end | |
end # at the end of the block it fires the requests in parallel and ... blocks | |
# when there's a single request, or the usage is explicitly serial, we do something like this | |
# unlike the above, fire! raises an exception if the request fails | |
@z = fire!(client.get_z(:user_id => 1, :id => 4)) | |
# we also have a version without a ! which doesn't raise an exception | |
@a = fire(client.get_z(:user_id => 1, :id => 4)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment