Skip to content

Commit

Permalink
Merge pull request #914 from oskarhane/fix-queing
Browse files Browse the repository at this point in the history
Block background queries until the prev is finished
  • Loading branch information
oskarhane authored Mar 25, 2019
2 parents 6145c99 + c00d967 commit 218c8be
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
5 changes: 4 additions & 1 deletion src/shared/modules/dbMeta/dbMetaDuck.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const UPDATE_SERVER = 'meta/UPDATE_SERVER'
export const UPDATE_SETTINGS = 'meta/UPDATE_SETTINGS'
export const CLEAR = 'meta/CLEAR'
export const FORCE_FETCH = 'meta/FORCE_FETCH'
export const DB_META_DONE = 'meta/DB_META_DONE'

/**
* Selectors
Expand Down Expand Up @@ -292,6 +293,8 @@ export const dbMetaEpic = (some$, store) =>
return (
Rx.Observable.timer(1, 20000)
.merge(some$.ofType(FORCE_FETCH))
// Throw away newly initiated calls until done
.throttle(() => some$.ofType(DB_META_DONE))
// Labels, types and propertyKeys
.mergeMap(() =>
Rx.Observable.fromPromise(
Expand Down Expand Up @@ -342,7 +345,7 @@ export const dbMetaEpic = (some$, store) =>
.filter(connectionLossFilter)
.merge(some$.ofType(DISCONNECTION_SUCCESS))
)
.mapTo({ type: 'NOOP' })
.mapTo({ type: DB_META_DONE })
)
})

Expand Down
35 changes: 20 additions & 15 deletions src/shared/modules/jmx/jmxDuck.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import { getBackgroundTxMetadata } from 'shared/services/bolt/txMetadata'
export const NAME = 'jmx'
export const UPDATE = NAME + '/UPDATE'
export const UPDATE_JMX_VALUES = NAME + '/UPDATE_JMX_VALUES'
export const UPDATE_JMX_VALUES_DONE = NAME + '/UPDATE_JMX_VALUES_DONE'

/**
* Selectors
Expand Down Expand Up @@ -140,20 +141,24 @@ export const jmxEpic = (some$, store) =>
.filter(s => s.state === CONNECTED_STATE)
.merge(some$.ofType(CONNECTION_SUCCESS))
.mergeMap(() => {
return Rx.Observable.timer(0, 20000)
.merge(some$.ofType(FORCE_FETCH))
.mergeMap(() =>
Rx.Observable.fromPromise(fetchJmxValues(store)).catch(() =>
Rx.Observable.of([])
return (
Rx.Observable.timer(0, 20000)
.merge(some$.ofType(FORCE_FETCH))
// Throw away new calls until we're finished
.throttle(() => some$.ofType(UPDATE_JMX_VALUES_DONE))
.mergeMap(() =>
Rx.Observable.fromPromise(fetchJmxValues(store)).catch(() =>
Rx.Observable.of([])
)
)
)
.filter(r => r)
.do(res => store.dispatch(updateJmxValues(res)))
.takeUntil(
some$
.ofType(LOST_CONNECTION)
.filter(connectionLossFilter)
.merge(some$.ofType(DISCONNECTION_SUCCESS))
)
.mapTo({ type: 'NOOP' })
.filter(r => r)
.do(res => store.dispatch(updateJmxValues(res)))
.takeUntil(
some$
.ofType(LOST_CONNECTION)
.filter(connectionLossFilter)
.merge(some$.ofType(DISCONNECTION_SUCCESS))
)
.mapTo({ type: UPDATE_JMX_VALUES_DONE })
)
})

0 comments on commit 218c8be

Please sign in to comment.