Skip to content

Commit

Permalink
fix: remove ensureQueueExists
Browse files Browse the repository at this point in the history
  • Loading branch information
samaratungajs committed Sep 10, 2024
1 parent 393cd73 commit 5939862
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions lib/pgboss.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class PgBossService {
data: TData,
options?: PgBoss.SendOptions,
) {
await this.ensureQueueExists(name);
await this.pgBoss.createQueue(name);
await this.pgBoss.send(name, data, options);
}

Expand All @@ -31,7 +31,7 @@ export class PgBossService {
data?: TData,
options?: PgBoss.ScheduleOptions,
) {
await this.ensureQueueExists(name);
await this.pgBoss.createQueue(name);
await this.pgBoss.schedule(name, cron, data ?? {}, options ?? {});
}

Expand All @@ -42,7 +42,7 @@ export class PgBossService {
data?: TData,
options?: PgBoss.ScheduleOptions,
) {
await this.ensureQueueExists(name);
await this.pgBoss.createQueue(name);
await this.pgBoss.schedule(name, cron, data ?? {}, options ?? {});
await this.pgBoss.work<TData>(
name,
Expand All @@ -56,18 +56,11 @@ export class PgBossService {
handler: WorkWithMetadataHandler<TData>,
options?: PgBoss.WorkOptions,
) {
await this.ensureQueueExists(name);
await this.pgBoss.createQueue(name);
await this.pgBoss.work<TData>(
name,
{ ...options, includeMetadata: true },
handler,
);
}

async ensureQueueExists(queueName: string) {
const currentQueue = await this.pgBoss.getQueue(queueName);
if (!currentQueue) {
await this.pgBoss.createQueue(queueName);
}
}
}

0 comments on commit 5939862

Please sign in to comment.