sproutcore/sproutcore — Issue #739: Review Datasource API to buffer calls
Author: mauritslamers
Created: 2012-03-07 16:33:38+00:00
State: open
Labels: proposal

The default behaviour of the store and data source at the moment is for the store to push all data source calls immediately to the data source.

This behaviour causes all kinds of problems:
- a getEach on a record array of any kind (RecordArray, ManyArray) causes a flurry of retrieveRecord calls
- the retrieveRecords API for combining retrieveRecord calls is effectively rendered useless because it is (almost) never called with multiple ids, making every single call a retrieveRecord call. Bundling of requests is therefore impossible.
- Allowing an application to send a flurry of for example 300+ retrieveRecord calls is an unintended DDoS waiting to happen
- An application has to be designed very carefully to prevent getEach calls on incomplete record arrays in order to prevent this flurry of calls.

My proposal for a solution is this:

The API from the Store to the Datasource should be changed in such a way that the default data source will buffer and group requests bases on model, and only call the user functions at the end of the runloop. This allows a proper use of the retrieveRecords, updateRecords and deleteRecords functions to bundle requests to the back end.