Skip to content

Commit

Permalink
chore: add queue concurrency as env
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed May 3, 2024
1 parent f0956d5 commit fe13178
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/graphql/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ SYNC_MISSING=
SERVER_BUILD=
IS_DEV_TEST=
SYNC_OFFSET=10
SYNC_LIMIT=1000

SYNC_LIMIT=10000
QUEUE_CONCURRENCY=500
4 changes: 2 additions & 2 deletions packages/graphql/.env.production
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ SYNC_MISSING=
SERVER_BUILD=
IS_DEV_TEST=
SYNC_OFFSET=10
SYNC_LIMIT=1000

SYNC_LIMIT=10000
QUEUE_CONCURRENCY=500
6 changes: 4 additions & 2 deletions packages/graphql/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand All @@ -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',
});
4 changes: 2 additions & 2 deletions packages/graphql/src/infra/queue/Queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export type QueueData<T = unknown> = Job<T>;

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 = {
Expand Down

0 comments on commit fe13178

Please sign in to comment.