Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ describe(JobQueueService.name, () => {
await service.registerHandlers([handler]);

expect(pgBoss.createQueue).toHaveBeenCalledWith("test", {
name: "test",
retryBackoff: true,
retryDelayMax: 300,
retryLimit: 5
Expand Down Expand Up @@ -48,13 +47,11 @@ describe(JobQueueService.name, () => {

expect(pgBoss.createQueue).toHaveBeenCalledTimes(2);
expect(pgBoss.createQueue).toHaveBeenCalledWith("test", {
name: "test",
retryBackoff: true,
retryDelayMax: 300,
retryLimit: 5
});
expect(pgBoss.createQueue).toHaveBeenCalledWith("another", {
name: "another",
retryBackoff: true,
retryDelayMax: 300,
retryLimit: 5
Expand Down Expand Up @@ -127,7 +124,6 @@ describe(JobQueueService.name, () => {
await service.startWorkers({ concurrency: 5 });

expect(pgBoss.createQueue).toHaveBeenCalledWith("test", {
name: "test",
retryBackoff: true,
retryDelayMax: 300,
retryLimit: 5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export class JobQueueService implements Disposable {
}
seenJobs.add(queueName);
await this.pgBoss.createQueue(queueName, {
name: queueName,
retryLimit: 5,
retryBackoff: true,
retryDelayMax: 5 * 60
Expand Down
2 changes: 1 addition & 1 deletion apps/notifications/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"murmurhash": "^2.0.1",
"nestjs-zod": "^4.3.1",
"pg": "^8.13.0",
"pg-boss": "^10.1.6",
"pg-boss": "^11.0.4",
"pino": "^9.7.0",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ describe("createPgBoss", () => {
expect(MockPgBoss).toHaveBeenCalledTimes(2);
expect(MockPgBoss.mock.calls[0][0]).toEqual(config["broker.EVENT_BROKER_POSTGRES_URI"]);
expect(MockPgBoss.mock.calls[1][0]).toEqual({
archiveCompletedAfterSeconds: config["broker.EVENT_BROKER_ARCHIVE_COMPLETED_AFTER_SECONDS"],
db: {
executeSql: expect.any(Function)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ export const createPgBossFactory =
executeSql(text: string, values: any[]): Promise<{ rows: any[] }> {
return client.query(text, values);
}
},
archiveCompletedAfterSeconds: config.getOrThrow("broker.EVENT_BROKER_ARCHIVE_COMPLETED_AFTER_SECONDS")
}
});

const logger = new LoggerService({ context: "PgBoss" });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ describe(BrokerService.name, () => {

await service.subscribe(eventName, options, handler);

expect(pgBoss.createQueue).toHaveBeenCalledWith(queueName);
expect(pgBoss.createQueue).toHaveBeenCalledWith(queueName, {
deleteAfterSeconds: configService.getOrThrow("broker.EVENT_BROKER_ARCHIVE_COMPLETED_AFTER_SECONDS")
});
expect(pgBoss.subscribe).toHaveBeenCalledWith(eventName, queueName);
expect(pgBoss.work).toHaveBeenCalledTimes(options.prefetchCount);
expect(pgBoss.work).toHaveBeenCalledWith(queueName, expect.any(Function));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ export class BrokerService {

async subscribe<ReqData>(eventName: string, options: { prefetchCount: number }, handler: SingleMsgWorkHandler<ReqData>) {
const queueName = this.toQueueName(eventName);
await this.boss.createQueue(queueName);
await this.boss.createQueue(queueName, {
deleteAfterSeconds: this.configService.getOrThrow("broker.EVENT_BROKER_ARCHIVE_COMPLETED_AFTER_SECONDS")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought(non-blocking): one important difference in v1 is that pg-boss no longer partition jobs table by default and if you need to enable this behavior, it should be explicit. https://timgit.github.io/pg-boss/#/./api/queues

Image

});
await this.boss.subscribe(eventName, queueName);

await Promise.all(
Expand Down
46 changes: 17 additions & 29 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading