Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support batch requests #50

Closed
arsduo opened this issue Mar 31, 2011 · 13 comments
Closed

Support batch requests #50

arsduo opened this issue Mar 31, 2011 · 13 comments

Comments

@arsduo
Copy link
Owner

arsduo commented Mar 31, 2011

http://developers.facebook.com/docs/api/batch/

@jobster
Copy link
Contributor

jobster commented Mar 31, 2011

Love it! This would be a really nice thing to have, especially since the return format for batch calls is really awkward, what with each response containing a header and code when all you really want is the return data.

@arsduo
Copy link
Owner Author

arsduo commented Apr 4, 2011

I'm tentatively thinking implementing batch via a block, something like

graph.batch do
g.op1
g.op2(args)
g.op3
end

The core api method, in batch mode, would queue up requests, and then execute them at the end of the block, returning a (simplified) array of responses as the result of the block.

Open to any thoughts/suggestions!

@marcgg
Copy link
Contributor

marcgg commented Apr 5, 2011

This is be a good idea since we would be able to keep on using regular koala syntax and just have to put it inside a block... So much easier to read!

The only problem I see with this is that - unless I'm missing something obvious - you wouldn't be able to specify a different access token for each request.

Maybe allowing things like the following would fix it:

graph = Koala::Facebook::GraphAPI.new(oauth_access_token)
other_graph = Koala::Facebook::GraphAPI.new(other_oauth_access_token)
Koala::Facebook::GraphAPI::Batch.run do
  graph.op1
  other_graph.op2
end

... or something like that. I'm not sure if a GraphAPI::Batch module is required or if using what's already in the lib would be enough.

@arsduo
Copy link
Owner Author

arsduo commented Apr 6, 2011

Great catch -- I hadn't thought of that use case, but it's a necessary and important one. I'll go the way you've proposed. I don't yet know if we'll add a batch module or just add a class-level batch method -- I'll sketch out my thoughts and post them here tomorrow, most likely.

@arsduo
Copy link
Owner Author

arsduo commented Apr 12, 2011

FYI, this will be part of release 1.1, which will be either late this month or sometime next month. Just got the last big 1.0 issue solved, so we'll hopefully get that out with the existing feature-set soon and then start on batch.

@arsduo
Copy link
Owner Author

arsduo commented Apr 25, 2011

FYI, I've started a branch for batch requests (https://github.com/arsduo/koala/tree/batch). So far I've laid the groundwork for batch operations by refactored the api method to use blocks heavily, which can then be stored for batch execution or executed immediately in normal use. Next step is to figure out how batch should work -- how to store the data, what response to give, etc. -- and deal with the whole "processing the awkward results" bit.

@amrnt
Copy link
Contributor

amrnt commented Apr 26, 2011

+1

@arsduo
Copy link
Owner Author

arsduo commented May 12, 2011

Hey everyone,

Good news update! I received a pull request this morning with a complete implementation of the Batch API. I'd been pulled away by an urgent non-Koala project halfway through my own implementation, so this was a nice surprise. seejohnrun implemented batch exactly as we'd been discussing and planning, and provided specs.

Note that this is just the basic batch API for a single token. I'll be modifying it as needed over the next week to support multiple tokens, dependencies, and other advance topics.

The diff is here: dea3d36. I'm pulling it into a separate branch now.

I'll be testing this as well as a few other things over the next few days, so feel free to try it out and share any feedback as well.

Alex

@arsduo
Copy link
Owner Author

arsduo commented May 23, 2011

Hey everyone,

I'm excited to let you know that Batch API support is complete! You can check it out at https://github.com/arsduo/koala/tree/batch. Big thanks to seejohnrun for his help, and to those who've sent feedback on the earlier versions.

We support all the Batch API features (basic batch operations, multiple access tokens, errors in results, dependencies, and uploading binary files). There's no documentation yet, but the specs for the Batch API contain easy-to-follow examples of everything it can do. You should, of course, also read Facebook's Batch API documentation, too (http://developers.facebook.com/docs/api/batch/).

If you have some time and energy, point your Gemfile to the git branch and give the Batch API a try. We'll be merging it into master soon and releasing the next version as a release candidate around the end of the month, hopefully, and I'll be glad for any feedback between now and then (or later, of course).

Cheers,

Alex

@arsduo arsduo closed this as completed May 23, 2011
@soleun
Copy link

soleun commented Nov 19, 2011

Is anyone getting "IOError: Connection reset by peer" when using batch calls?

@arsduo
Copy link
Owner Author

arsduo commented Nov 25, 2011

I haven't seen that. Is it still happening?

On Nov 19, 2011, at 10:53 PM, Sol Eun wrote:

Is anyone getting "IOError: Connection reset by peer" when using batch calls?


Reply to this email directly or view it on GitHub:
#50 (comment)

@marcgg
Copy link
Contributor

marcgg commented Nov 27, 2011

@soleun: I get that every once in a while. It's due to Facebook API's general instability. Also there were additional stability issues with the BatchAPI a few days back: http://developers.facebook.com/bugs/308579742503979?

@soleun
Copy link

soleun commented Nov 29, 2011

@marcgg Thanks for the response. I got around this by not keeping the connection open for too long.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants