mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
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 builder = new addonBuilder(dummyManifest());
|
||||||
const limiter = new Bottleneck({
|
const limiter = new Bottleneck({
|
||||||
maxConcurrent: process.env.LIMIT_MAX_CONCURRENT || 200,
|
maxConcurrent: process.env.LIMIT_MAX_CONCURRENT || 100,
|
||||||
highWater: process.env.LIMIT_QUEUE_SIZE || 220,
|
highWater: process.env.LIMIT_QUEUE_SIZE || 120,
|
||||||
strategy: Bottleneck.strategy.OVERFLOW
|
strategy: Bottleneck.strategy.OVERFLOW
|
||||||
});
|
});
|
||||||
const limiterOptions = { expiration: 2 * 60 * 1000 }
|
const limiterOptions = { expiration: 2 * 60 * 1000 }
|
||||||
@@ -29,7 +29,7 @@ builder.defineStreamHandler((args) => {
|
|||||||
return Promise.resolve({ streams: [] });
|
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
|
.then(records => records
|
||||||
.sort((a, b) => b.torrent.seeders - a.torrent.seeders || b.torrent.uploadDate - a.torrent.uploadDate)
|
.sort((a, b) => b.torrent.seeders - a.torrent.seeders || b.torrent.uploadDate - a.torrent.uploadDate)
|
||||||
.map(record => toStreamInfo(record)))))
|
.map(record => toStreamInfo(record)))))
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ function initiateRemoteCache() {
|
|||||||
uri: MONGO_URI,
|
uri: MONGO_URI,
|
||||||
options: {
|
options: {
|
||||||
collection: 'torrentio_addon_collection',
|
collection: 'torrentio_addon_collection',
|
||||||
socketTimeoutMS: 120000,
|
socketTimeoutMS: 30000,
|
||||||
useNewUrlParser: true,
|
useNewUrlParser: true,
|
||||||
useUnifiedTopology: false,
|
useUnifiedTopology: false,
|
||||||
ttl: STREAM_EMPTY_TTL
|
ttl: STREAM_EMPTY_TTL
|
||||||
|
|||||||
Reference in New Issue
Block a user