atom feed45 messages in com.googlegroups.opensocial-and-gadgets-specRe: [osgs] Re: Batch Support in RPC P...
FromSent OnAttachments
James SnellJan 26, 2012 1:35 pm 
James SnellJan 26, 2012 1:35 pm 
Henry SaputraJan 26, 2012 8:34 pm 
Henry SaputraJan 26, 2012 8:34 pm 
Mark W.Jan 30, 2012 5:20 am 
James SnellJan 30, 2012 8:08 am 
James SnellJan 30, 2012 8:08 am 
Mark W.Jan 30, 2012 11:05 am 
Matthew MarumFeb 2, 2012 1:22 pm 
Li XuFeb 3, 2012 8:05 am 
Li XuFeb 3, 2012 8:05 am 
Mark W.Feb 3, 2012 8:18 am 
Matthew MarumFeb 3, 2012 9:09 am 
Matthew MarumFeb 3, 2012 9:09 am 
James SnellFeb 3, 2012 2:15 pm 
James SnellFeb 3, 2012 2:16 pm 
Bastian HofmannFeb 5, 2012 3:25 am 
Bastian HofmannFeb 5, 2012 3:25 am 
Mark W.Feb 6, 2012 3:39 pm 
James SnellFeb 6, 2012 3:43 pm 
James SnellFeb 6, 2012 3:43 pm 
Laurent-Walter GoixFeb 7, 2012 2:26 pm 
James SnellFeb 7, 2012 4:25 pm 
James SnellFeb 7, 2012 4:25 pm 
Henry SaputraFeb 7, 2012 4:44 pm 
Henry SaputraFeb 7, 2012 4:44 pm 
Mark W.Feb 7, 2012 5:50 pm 
James SnellFeb 7, 2012 7:47 pm 
James SnellFeb 7, 2012 7:47 pm 
Henry SaputraFeb 7, 2012 8:13 pm 
Henry SaputraFeb 7, 2012 8:13 pm 
James SnellFeb 7, 2012 8:21 pm 
James SnellFeb 7, 2012 8:21 pm 
Henry SaputraFeb 7, 2012 8:37 pm 
Henry SaputraFeb 7, 2012 8:38 pm 
James SnellFeb 7, 2012 8:48 pm 
James SnellFeb 7, 2012 8:48 pm 
Craig McClanahanFeb 7, 2012 9:22 pm 
Craig McClanahanFeb 7, 2012 9:22 pm 
James SnellFeb 7, 2012 10:26 pm 
James SnellFeb 7, 2012 10:26 pm 
Mark W.Feb 8, 2012 9:05 am 
James SnellFeb 8, 2012 9:22 am 
James SnellFeb 8, 2012 9:22 am 
Mark W.Feb 9, 2012 8:33 am 
Subject:Re: [osgs] Re: Batch Support in RPC Protocol: A quick survey
From:James Snell (jasn@gmail.com)
Date:Feb 7, 2012 8:21:03 pm
List:com.googlegroups.opensocial-and-gadgets-spec

So if I'm reading this correctly, it's basically just a call to retrieve the profile and the activity stream for @me, right?

GET /api/@me/@self,@stream HTTP/1.1 Host: api.example.org Authorization: hh5s93j4hdidpola

Which can return something as simple as...

{ "@self": { // the profile }, "@stream": { // the stream } }

- James

On Tue, Feb 7, 2012 at 8:14 PM, Henry Saputra <henr@gmail.com> wrote:

How about request like this:

POST /rpc HTTP/1.1  Host: api.example.org  Authorization: hh5s93j4hdidpola  Content-Type: application/json  [   {     "method" : "people.get",     "id" : "myself",     "params" : {       "userId" : "@me",       "groupId" : "@self"     }   },   {     "method" : "activitystreams.get",     "id" : "mystreams",     "params" : {       "userId" : "@me",       "groupId" : "@self"     }   }  ]

One way to use REST is to have a universal object data type so we could have something like:

GET
/universalobject/@me/@self?objecttypes=people:activitystreams&people_userId=@me&people_groupId=@self&activitystreams_userId=@me&activitystreams_groupId=@self

Overloading REST to do this kind of request probably not a good and clean way.

Another way, like Matthew Marum has said, we could piggyback activitystreams request to the field response of the person. But this way force developers to be "creative"  to find out how to send batch requests for different data types.

Not sure if either way is the best way to achieve multi data types requests.

On Tue, Feb 7, 2012 at 7:47 PM, James Snell <jasn@gmail.com> wrote:

Mark,

Given the way things are currently defined in the API's, I have little doubt that batching helps performance, but that's not really the point I'm trying to make...

Consider this:
http://roy.gbiv.com/untangled/2008/rest-apis-must-be-hypertext-driven#comment-743.

The salient points: "People perceive a need for batch operations because they don’t understand the scope of resources... [t]he same resource state can be overlayed by multiple resources, just as an XML document can be represented as a sequence of bytes or a tree of individually addressable nodes. Likewise, a single resource can be the equivalent of a database stored procedure, with the power to abstract state changes over any number of storage items... If you find yourself in need of a batch operation, then most likely you just haven’t defined enough resources."

Let's look at the case you brought up in your earlier message. You said: "So you get a collection of users, batch up the ones you want to know more about and away you go."

My question to this is: why do we need a "batch" request?

Consider.. this is what a current RPC batch request currently looks like in the RPC model..

 POST /rpc HTTP/1.1  Host: api.example.org  Authorization: hh5s93j4hdidpola  Content-Type: application/json  [    {      "method" : "people.get",      "id" : "myself",      "params" : {        "userId" : "@me",        "groupId" : "@self"      }    },    {      "method" : "people.get",      "id" : "myfriends",      "params" : {        "userId" : "@me",        "groupId" : "@friends"      }    }  ]

The thing that strikes me as very odd about this is.. why isn't it just...

 POST /rpc HTTP/1.1  Host: api.example.org  Authorization: hh5s93j4hdidpola  Content-Type: application/json    {      "method" : "people.get",      "id" : "myself",      "params" : {        "userId" : "@me",        "groups": ["@self","@friends"]        }      ]    }

Or even better...

 GET /people/@me/@self,@friends HTTP/1.1  Host: api.example.org  Authorization: hh5s93j4hdidpola

From everything that I can see, the *ONLY* reason batching is required here is because of how the people.get operation is currently defined. With either of the two alternatives I suggest, the requirement for a batch request completely disappears. The GET option would be WAY more efficient than the POST /rpc with a batch request option could ever be. Period.

In your note you also said that another case "is to retrieve more information about the "stuff" a user has, e.g. blogs, documents, discussions, etc. " ... to which the natural question is: Well, why isn't there a single operation that would allow you to retrieve this information? I'd argue, as Roy suggests in the quote above, the only reason you'd need to batch requests to get the data you need is because we have created enough resources. We can take the time now to define those missing resources, and we can take the time to define something like the Persistent Query Service and better search and filter capabilities to completely eliminate the need for batching requests altogether.

We simply need to define new resources that provide all the information we need.

If you still think batching is an absolute requirement, let's put it to a test... show me a use case that absolutely requires batch request capability and if I'm not able to demonstrate that the same case can be implemented more efficiently without batching, I'll concede on the point.

On Tue, Feb 7, 2012 at 5:50 PM, Mark W. <weit@gmail.com> wrote:

James, It's interesting, because we've seen the opposite--that batching requests actually helps performance. I also think the current batch model is pretty clear that you get a dictionary with the key/value pairs. What use cases have you seen where changing the data model has made batching unnecessary? Could you give a more concrete example?

To post to this group, send email to open@googlegroups.com. To unsubscribe from this group, send email to opensocial-and-gadgets-spec+unsu@googlegroups.com. For more options, visit this group at http://groups.google.com/group/opensocial-and-gadgets-spec?hl=en.