move limiter before mongo call

This commit is contained in:
TheBeastLT
2024-01-21 23:14:44 +02:00
parent 8a4eb4cdfe
commit 4ee220a1ad
2 changed files with 4 additions and 4 deletions

View File

@@ -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)))))

View File

@@ -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