son_of_a_batch
Smelt from a plentiferous gallimaufry of requests an agglomerated bale of responses. With, y’know, concurrency and all that.
Install this as a shim to allow batch requests against a remote API.
h2.
Results vs Errors
Note that a request may do any of the following:
- The request might complete and be successful (eg
200 OK
). Each of these will be in the “results” block, with its status code set appropriately. - The request might complete but be unsuccessful (eg
404 Not Found
). These are no different to son_of_a_batch, so each of them will also be in the “results” block with its status code set appropriately. - The request might not complete. These will be in the “errors” block.
Usage
Start a test server:
$ ruby app/endpoints/sleepy.rb -sv -p 9002 # an example endpoint that sleeps a given amount of time before responding.
[54941:INFO] 2011-04-23 17:22:37 :: Starting server on 0.0.0.0:9002 in development mode. Watch out for stones.
$ curl 'http://localhost:9002?delay=2.2'
{"start":1303597564.663358,"delay":2.2,"actual":2.2001771926879883}
Start the son_of_a_batch server:
$ ruby app/endpoints/sleepy.rb -sv -p 9002 # an example endpoint that sleeps a given amount of time before responding.
[54941:INFO] 2011-04-23 17:22:37 :: Starting server on 0.0.0.0:9002 in development mode. Watch out for stones.
$ curl 'http://localhost:9002?delay=2.2'
{"start":1303597564.663358,"delay":2.2,"actual":2.2001771926879883}
Colophon
Uses
- Goliath — fast asynchronous API library
- Gorillib — only the lightest of weight helpers plucked from active_support and friends, with nothing obtrusive required by default.
Credits
Built using goliath, gorillib, and the infochimps API
Contributing to son_of_a_batch
- Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet
- Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it
- Fork the project
- Start a feature/bugfix branch
- Commit and push until you are happy with your contribution
- Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.
- Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
Copyright
Copyright © 2011 Philip (flip) Kromer for Infochimps. See LICENSE.txt for further details.