diff --git a/lib/pgboss.service.ts b/lib/pgboss.service.ts index a77c1d5..ac18721 100644 --- a/lib/pgboss.service.ts +++ b/lib/pgboss.service.ts @@ -5,9 +5,14 @@ import { PGBOSS_TOKEN } from "./utils/consts"; @Injectable() export class PgBossService { - public boss: PgBoss; + private pgBoss: PgBoss; + constructor(@Inject(PGBOSS_TOKEN) boss: PgBoss) { - this.boss = boss; + this.pgBoss = boss; + } + + get boss(): PgBoss { + return this.pgBoss; } async scheduleJob( @@ -15,7 +20,7 @@ export class PgBossService { data: TData, options?: PgBoss.SendOptions, ) { - await this.boss.send(name, data, options); + await this.pgBoss.send(name, data, options); } async scheduleCronJob( @@ -24,7 +29,7 @@ export class PgBossService { data?: TData, options?: PgBoss.ScheduleOptions, ) { - await this.boss.schedule(name, cron, data ?? {}, options ?? {}); + await this.pgBoss.schedule(name, cron, data ?? {}, options ?? {}); } async registerCronJob( @@ -34,8 +39,8 @@ export class PgBossService { data?: TData, options?: PgBoss.ScheduleOptions, ) { - await this.boss.schedule(name, cron, data ?? {}, options ?? {}); - await this.boss.work( + await this.pgBoss.schedule(name, cron, data ?? {}, options ?? {}); + await this.pgBoss.work( name, { ...options, includeMetadata: true }, handler, @@ -47,7 +52,7 @@ export class PgBossService { handler: WorkWithMetadataHandler, options?: PgBoss.BatchWorkOptions, ) { - await this.boss.work( + await this.pgBoss.work( name, { ...options, includeMetadata: true }, handler,