GithubHelp home page GithubHelp logo

Support batch requests about koala HOT 13 CLOSED

arsduo avatar arsduo commented on May 18, 2024
Support batch requests

from koala.

Comments (13)

jobster avatar jobster commented on May 18, 2024

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.

from koala.

arsduo avatar arsduo commented on May 18, 2024

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!

from koala.

marcgg avatar marcgg commented on May 18, 2024

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.

from koala.

arsduo avatar arsduo commented on May 18, 2024

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.

from koala.

arsduo avatar arsduo commented on May 18, 2024

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.

from koala.

arsduo avatar arsduo commented on May 18, 2024

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.

from koala.

amrnt avatar amrnt commented on May 18, 2024

+1

from koala.

arsduo avatar arsduo commented on May 18, 2024

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

from koala.

arsduo avatar arsduo commented on May 18, 2024

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

from koala.

soleun avatar soleun commented on May 18, 2024

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

from koala.

arsduo avatar arsduo commented on May 18, 2024

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)

from koala.

marcgg avatar marcgg commented on May 18, 2024

@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?

from koala.

soleun avatar soleun commented on May 18, 2024

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

from koala.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.