Skip to content

Commit

Permalink
fix: getter for boss instance added
Browse files Browse the repository at this point in the history
  • Loading branch information
samaratungajs committed Sep 8, 2024
1 parent 0c9badf commit 6ebd140
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions lib/pgboss.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,22 @@ 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<TData extends object>(
name: string,
data: TData,
options?: PgBoss.SendOptions,
) {
await this.boss.send(name, data, options);
await this.pgBoss.send(name, data, options);
}

async scheduleCronJob<TData extends object>(
Expand All @@ -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<TData extends object>(
Expand All @@ -34,8 +39,8 @@ export class PgBossService {
data?: TData,
options?: PgBoss.ScheduleOptions,
) {
await this.boss.schedule(name, cron, data ?? {}, options ?? {});
await this.boss.work<TData>(
await this.pgBoss.schedule(name, cron, data ?? {}, options ?? {});
await this.pgBoss.work<TData>(
name,
{ ...options, includeMetadata: true },
handler,
Expand All @@ -47,7 +52,7 @@ export class PgBossService {
handler: WorkWithMetadataHandler<TData>,
options?: PgBoss.BatchWorkOptions,
) {
await this.boss.work<TData>(
await this.pgBoss.work<TData>(
name,
{ ...options, includeMetadata: true },
handler,
Expand Down

0 comments on commit 6ebd140

Please sign in to comment.