From fe13178fcef5140064ad66c4b524db0524268088 Mon Sep 17 00:00:00 2001 From: Pedro Nauck Date: Thu, 2 May 2024 22:47:35 -0300 Subject: [PATCH] chore: add queue concurrency as env --- packages/graphql/.env.example | 4 ++-- packages/graphql/.env.production | 4 ++-- packages/graphql/src/config.ts | 6 ++++-- packages/graphql/src/infra/queue/Queue.ts | 4 ++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/graphql/.env.example b/packages/graphql/.env.example index 8b3350b7f..dbc0994d1 100644 --- a/packages/graphql/.env.example +++ b/packages/graphql/.env.example @@ -11,5 +11,5 @@ SYNC_MISSING= SERVER_BUILD= IS_DEV_TEST= SYNC_OFFSET=10 -SYNC_LIMIT=1000 - +SYNC_LIMIT=10000 +QUEUE_CONCURRENCY=500 diff --git a/packages/graphql/.env.production b/packages/graphql/.env.production index 1af8b211f..c87ec7278 100644 --- a/packages/graphql/.env.production +++ b/packages/graphql/.env.production @@ -11,5 +11,5 @@ SYNC_MISSING= SERVER_BUILD= IS_DEV_TEST= SYNC_OFFSET=10 -SYNC_LIMIT=1000 - +SYNC_LIMIT=10000 +QUEUE_CONCURRENCY=500 diff --git a/packages/graphql/src/config.ts b/packages/graphql/src/config.ts index 06dbfd69a..cdf511d98 100644 --- a/packages/graphql/src/config.ts +++ b/packages/graphql/src/config.ts @@ -16,7 +16,8 @@ const schema = zod.object({ SERVER_BUILD: falsy.optional(), IS_DEV_TEST: falsy.optional(), SYNC_OFFSET: zod.string().optional().default('10'), - SYNC_LIMIT: zod.string().optional().default('1000'), + SYNC_LIMIT: zod.string().optional().default('10000'), + QUEUE_CONCURRENCY: zod.string().optional().default('500'), }); export const env = new Env(schema, { @@ -32,5 +33,6 @@ export const env = new Env(schema, { SYNC_MISSING: false, IS_DEV_TEST: false, SYNC_OFFSET: '10', - SYNC_LIMIT: '1000', + SYNC_LIMIT: '10000', + QUEUE_CONCURRENCY: '500', }); diff --git a/packages/graphql/src/infra/queue/Queue.ts b/packages/graphql/src/infra/queue/Queue.ts index d375491e9..1cdace9b9 100644 --- a/packages/graphql/src/infra/queue/Queue.ts +++ b/packages/graphql/src/infra/queue/Queue.ts @@ -41,8 +41,8 @@ export type QueueData = Job; export class Queue extends PgBoss { private workOpts: PgBoss.WorkOptions = { - teamSize: 500, - teamConcurrency: 500, + teamSize: Number(env.get('QUEUE_CONCURRENCY')), + teamConcurrency: Number(env.get('QUEUE_CONCURRENCY')), }; static defaultJobOptions: PgBoss.RetryOptions = {