Skip to content

Commit 1797f29

Browse files
committed
optimization, scheduling pull
1 parent 81006a0 commit 1797f29

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

packages/bolt-connection/src/bolt/stream-observers.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ class ResultStreamObserver extends StreamObserver {
9595
this._setState(reactive ? _states.READY : _states.READY_STREAMING)
9696
this._setupAuoPull(fetchSize)
9797
this._pullMode = false;
98+
this._pullScheduled = false;
9899
}
99100

100101
setPullMode(pullMode) {
@@ -360,10 +361,11 @@ class ResultStreamObserver extends StreamObserver {
360361

361362
_handleStreaming () {
362363
if (this._head && this._observers.some(o => o.onNext || o.onCompleted)) {
363-
if (!this._pullMode && (this._discard || this._autoPull)) {
364+
if (!this._pullMode && (this._discard || this._autoPull) || this._pullScheduled) {
364365
this._more()
365366
}
366367
}
368+
this._pullScheduled = false
367369
}
368370

369371
_more () {
@@ -373,6 +375,11 @@ class ResultStreamObserver extends StreamObserver {
373375
this._moreFunction(this._queryId, this._fetchSize, this)
374376
}
375377
this._setState(_states.STREAMING)
378+
this._pullScheduled = false
379+
}
380+
381+
_schedulePull () {
382+
this._pullScheduled = true
376383
}
377384

378385
_storeMetadataForCompletion (meta) {
@@ -631,7 +638,7 @@ const _states = {
631638
name: () => {
632639
return 'STREAMING'
633640
},
634-
pull: () => {}
641+
pull: streamObserver => streamObserver._schedulePull()
635642
},
636643
FAILED: {
637644
onError: error => {

0 commit comments

Comments
 (0)