Page MenuHomePhabricator

give API an id type parameter for parallel operations
Closed, ResolvedPublic

Description

Author: herd

Description:
Often when working with the API I'll end up needing to do several parallel operations, such as with format=json and using callbacks. This can be annoying, requiring re-scraping the page to figure out what triggered what, and doing fragile matching in the process.

An alternative I've found is to use eval() to generate a unique callback function for each object, eg:

var url = wgServer + wgScriptPath + '/api.php?action=query&format=json&callback=usiCB' + i;

eval('usiCB' + i + ' = function(tobj) { usiCB(tobj,' + i + ')}');

But this can be a pain for hundreds of parallel or potential operations. Per IRC convo with Roan a possible solution vector is a generic ID parameter for all formats:

something like &requestid=foo or &apiid=foo could generate (in the various formats):

({
"id":"foo",
"query": {
},
})

<api id="foo">

array('api' => array('id' => 'foo', 'query' => ...

This would greatly facilitate usage of parallel scripts by giving the calling code a way to trace back what requested the query.


Version: unspecified
Severity: enhancement

Details

Reference
bz15044

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:19 PM
bzimport set Reference to bz15044.