move limiter before mongo call
This commit is contained in:
@@ -18,8 +18,8 @@ const STALE_ERROR_AGE = 7 * 24 * 60 * 60; // 7 days
|
||||
|
||||
const builder = new addonBuilder(dummyManifest());
|
||||
const limiter = new Bottleneck({
|
||||
maxConcurrent: process.env.LIMIT_MAX_CONCURRENT || 200,
|
||||
highWater: process.env.LIMIT_QUEUE_SIZE || 220,
|
||||
maxConcurrent: process.env.LIMIT_MAX_CONCURRENT || 100,
|
||||
highWater: process.env.LIMIT_QUEUE_SIZE || 120,
|
||||
strategy: Bottleneck.strategy.OVERFLOW
|
||||
});
|
||||
const limiterOptions = { expiration: 2 * 60 * 1000 }
|
||||
@@ -29,7 +29,7 @@ builder.defineStreamHandler((args) => {
|
||||
return Promise.resolve({ streams: [] });
|
||||
}
|
||||
|
||||
return cacheWrapStream(args.id, () => limiter.schedule(limiterOptions, () => streamHandler(args)
|
||||
return limiter.schedule(limiterOptions, () => cacheWrapStream(args.id, () => streamHandler(args)
|
||||
.then(records => records
|
||||
.sort((a, b) => b.torrent.seeders - a.torrent.seeders || b.torrent.uploadDate - a.torrent.uploadDate)
|
||||
.map(record => toStreamInfo(record)))))
|
||||
|
||||
@@ -29,7 +29,7 @@ function initiateRemoteCache() {
|
||||
uri: MONGO_URI,
|
||||
options: {
|
||||
collection: 'torrentio_addon_collection',
|
||||
socketTimeoutMS: 120000,
|
||||
socketTimeoutMS: 30000,
|
||||
useNewUrlParser: true,
|
||||
useUnifiedTopology: false,
|
||||
ttl: STREAM_EMPTY_TTL
|
||||
|
||||
Reference in New Issue
Block a user