From 4f249159d310d4296753fcfe8e2bbd390fd9002b Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 18 Mar 2021 11:17:05 +0900 Subject: Improve chart performance (#7360) * wip * wip * wip * wip * wip * Update chart.ts * wip * Improve server performance * wip * wip --- src/queue/initialize.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/queue/initialize.ts (limited to 'src/queue/initialize.ts') diff --git a/src/queue/initialize.ts b/src/queue/initialize.ts new file mode 100644 index 0000000000..92579531e4 --- /dev/null +++ b/src/queue/initialize.ts @@ -0,0 +1,18 @@ +import * as Queue from 'bull'; +import config from '../config'; + +export function initialize(name: string, limitPerSec = -1) { + return new Queue(name, { + redis: { + port: config.redis.port, + host: config.redis.host, + password: config.redis.pass, + db: config.redis.db || 0, + }, + prefix: config.redis.prefix ? `${config.redis.prefix}:queue` : 'queue', + limiter: limitPerSec > 0 ? { + max: limitPerSec * 5, + duration: 5000 + } : undefined + }); +} -- cgit v1.2.3-freya