mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Backport PR #6651
--------- **Commit 1:** [courier/segmentedRequest] mark the request "started" synchronously * Original sha:8a4992640b
* Authored by spalger <spalger@users.noreply.github.com> on 2016-03-24T21:35:00Z **Commit 2:** [courier/fetch] detect aborted requests more agressively * Original sha:c12f18df27
* Authored by spalger <spalger@users.noreply.github.com> on 2016-03-24T21:35:46Z **Commit 3:** [courier/callClient] if there are no executable requests, do nothing * Original sha:8fef03b816
* Authored by spalger <spalger@users.noreply.github.com> on 2016-03-24T21:36:18Z **Commit 4:** [courier/tests] updated test * Original sha:985f9970f3
* Authored by spalger <spalger@users.noreply.github.com> on 2016-03-24T22:25:31Z
This commit is contained in:
parent
7a5a7ac03b
commit
7fe9e9c062
4 changed files with 15 additions and 9 deletions
|
@ -16,6 +16,8 @@ define(function (require) {
|
|||
var executable = statuses.filter(isRequest);
|
||||
var execCount = executable.length;
|
||||
|
||||
if (!execCount) return Promise.resolve([]);
|
||||
|
||||
// resolved by respond()
|
||||
var esPromise;
|
||||
var defer = Promise.defer();
|
||||
|
|
|
@ -23,22 +23,26 @@ define(function (require) {
|
|||
}
|
||||
|
||||
function fetchWithStrategy(strategy, requests) {
|
||||
function replaceAbortedRequests() {
|
||||
requests = requests.map(r => r.aborted ? ABORTED : r);
|
||||
}
|
||||
|
||||
requests = requests.map(function (req) {
|
||||
return req.aborted ? ABORTED : req;
|
||||
});
|
||||
|
||||
replaceAbortedRequests();
|
||||
return startRequests(requests)
|
||||
.then(function () {
|
||||
replaceAbortedRequests();
|
||||
return callClient(strategy, requests);
|
||||
})
|
||||
.then(function (responses) {
|
||||
replaceAbortedRequests();
|
||||
return callResponseHandlers(requests, responses);
|
||||
})
|
||||
.then(function (responses) {
|
||||
replaceAbortedRequests();
|
||||
return continueIncomplete(strategy, requests, responses, fetchWithStrategy);
|
||||
})
|
||||
.then(function (responses) {
|
||||
replaceAbortedRequests();
|
||||
return responses.map(function (resp) {
|
||||
switch (resp) {
|
||||
case ABORTED:
|
||||
|
|
|
@ -29,9 +29,7 @@ describe('ui/courier/fetch/request/segmented', () => {
|
|||
expect(returned.then).to.be.Function;
|
||||
});
|
||||
|
||||
it('does not call super.start() until promise is resolved', () => {
|
||||
expect(searchReqStart.called).to.be(false);
|
||||
$rootScope.$apply();
|
||||
it('calls super.start() synchronously', () => {
|
||||
expect(searchReqStart.called).to.be(true);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -39,6 +39,8 @@ define(function (require) {
|
|||
SegmentedReq.prototype.start = function () {
|
||||
var self = this;
|
||||
|
||||
SearchReq.prototype.start.call(this);
|
||||
|
||||
this._complete = [];
|
||||
this._active = null;
|
||||
this._segments = [];
|
||||
|
@ -58,12 +60,12 @@ define(function (require) {
|
|||
// parameters via the handle
|
||||
if (_.isFunction(this._initFn)) this._initFn(this._handle);
|
||||
return this._createQueue().then(function (queue) {
|
||||
if (self.stopped) return;
|
||||
|
||||
self._all = queue.slice(0);
|
||||
|
||||
// Send the initial fetch status
|
||||
self._reportStatus();
|
||||
|
||||
return SearchReq.prototype.start.call(self);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue