Skip to content

Commit

Permalink
Applied hack for temporarily fixing issue with limiter.
Browse files Browse the repository at this point in the history
  • Loading branch information
lpaolini committed Jan 16, 2020
1 parent 4ac750f commit f77f87d
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions modules/gee/docker/src/pool.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const {Subject, timer, of, concat} = require('rxjs')
const {Subject, from, timer, of, concat} = require('rxjs')
const {tap, map, mergeMap, takeUntil, mapTo, filter, finalize, switchMap} = require('rxjs/operators')
const {v4: uuid} = require('uuid')
const _ = require('lodash')
const log = require('sepal/log')('pool')
const {Limiter$} = require('sepal/service/limiter')
// const {Limiter$} = require('./limiter')

const Pool = ({name, maxIdleMilliseconds = 1000, minIdleCount = 0, create$, onCold, onHot, onRelease, onDispose, onKeep, onMsg}) => {
const pool = []
Expand Down Expand Up @@ -113,15 +114,22 @@ const LimitedPool = ({rateWindowMs, maxRate, maxConcurrency, create$, ...args})
name: 'LimitedPool concurrency',
maxConcurrency
})
const pool = Pool({...args, create$: instanceId => {
return rateLimiter$().pipe(
mergeMap(() => create$(instanceId))
)
}})
const pool = Pool({
...args,
create$: instanceId =>
from( // [HACK] https://github.com/ReactiveX/rxjs/issues/5237
rateLimiter$()
).pipe(
mergeMap(() => create$(instanceId))
)
})
return {
getInstance$: () => concurrencyLimiter$().pipe(
mergeMap(() => pool.getInstance$())
)
getInstance$: () =>
from( // [HACK] https://github.com/ReactiveX/rxjs/issues/5237
concurrencyLimiter$()
).pipe(
mergeMap(() => pool.getInstance$())
)
}
}

Expand Down

0 comments on commit f77f87d

Please sign in to comment.