Skip to content

Commit

Permalink
Extract bull queue concurrency to env variable and disable rate limit
Browse files Browse the repository at this point in the history
  • Loading branch information
nonumpa committed Jan 30, 2021
1 parent a7e3ec6 commit a04a06c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
4 changes: 4 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,12 @@ REVIEW_REPLY_BUFFER={"seconds":0,"minutes":0,"hours":-12,"days":0}
# LINE add friend url, used for the message to guide user from LINE Notify to cofacts
LINE_FRIEND_URL=https://line.me/R/ti/p/@cofacts

# Dialogflow
DAILOGFLOW_CLIENT_EMAIL=
DAILOGFLOW_PRIVATE_KEY=
DAILOGFLOW_PROJECT_ID=
DAILOGFLOW_LANGUAGE=
DAILOGFLOW_ENV=

# Bull queue processor concurrency
JOBQUEUE_CONCURRENCY=3
6 changes: 5 additions & 1 deletion src/webhook/handlers/groupHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ export default class {
* @param {Bull.Queue} expiredJobQueue
* @returns {object}
*/
constructor(jobQueue, expiredJobQueue, concurrency = 1) {
constructor(
jobQueue,
expiredJobQueue,
concurrency = process.env.JOBQUEUE_CONCURRENCY || 3
) {
this.expiredJobQueue = expiredJobQueue;
this.jobQueue = jobQueue;

Expand Down
10 changes: 3 additions & 7 deletions src/webhook/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,17 +309,13 @@ const router = Router();

const groupEventQueue = new Bull('groupEventQueue', {
redis: process.env.REDIS_URL || 'redis://127.0.0.1:6379',
limiter: { max: 600, duration: 10 * 1000 },
// limiter: { max: 600, duration: 10 * 1000 },
});
const expiredGroupEventQueue = new Bull('expiredGroupEventQueue', {
redis: process.env.REDIS_URL || 'redis://127.0.0.1:6379',
limiter: { max: 600, duration: 10 * 1000 },
// limiter: { max: 600, duration: 10 * 1000 },
});
const groupHandler = new GroupHandler(
groupEventQueue,
expiredGroupEventQueue,
3
);
const groupHandler = new GroupHandler(groupEventQueue, expiredGroupEventQueue);
// Routes that is after protection of checkSignature
//
router.use('/', checkSignatureAndParse);
Expand Down

0 comments on commit a04a06c

Please sign in to comment.