@maroonedsoftware/jobbroker 1.4.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +23 -6
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -71,24 +71,25 @@ registry.set('daily-report', {
71
71
  import 'reflect-metadata';
72
72
  import { PgBoss } from 'pg-boss';
73
73
  import { InjectKitRegistry } from 'injectkit';
74
+ import { ConsoleLogger, Logger } from '@maroonedsoftware/logger';
74
75
  import { PgBossJobBroker, PgBossJobRunner, PgBossJobRegistryMap, JobBroker, JobRunner } from '@maroonedsoftware/jobbroker';
75
76
 
76
77
  // Initialize pg-boss
77
78
  const pgboss = new PgBoss('postgres://user:pass@localhost/mydb');
78
- await pgboss.start();
79
79
 
80
80
  // Set up dependency injection registry
81
81
  const diRegistry = new InjectKitRegistry();
82
82
 
83
83
  diRegistry.register(PgBossJobRegistryMap).useInstance(registry);
84
84
  diRegistry.register(PgBoss).useInstance(pgboss);
85
+ diRegistry.register(Logger).useClass(ConsoleLogger).asSingleton();
85
86
  diRegistry.register(JobBroker).useClass(PgBossJobBroker).asSingleton();
86
87
  diRegistry.register(JobRunner).useClass(PgBossJobRunner).asSingleton();
87
88
 
88
89
  // Build the container
89
90
  const container = diRegistry.build();
90
91
 
91
- // Start the job runner
92
+ // Start the job runner (this also calls pgboss.start() internally)
92
93
  const runner = container.get(JobRunner);
93
94
  await runner.start();
94
95
  ```
@@ -126,7 +127,7 @@ Abstract base class for job handlers.
126
127
 
127
128
  ### `JobBroker`
128
129
 
129
- Abstract interface for sending jobs to the queue.
130
+ Abstract base class for sending jobs to the queue.
130
131
 
131
132
  | Method | Description |
132
133
  | --------------------------------------------------------------------- | ------------------------------------ |
@@ -136,7 +137,7 @@ Abstract interface for sending jobs to the queue.
136
137
 
137
138
  ### `JobRunner`
138
139
 
139
- Abstract interface for processing jobs from the queue.
140
+ Abstract base class for processing jobs from the queue.
140
141
 
141
142
  | Method | Description |
142
143
  | ------------------------ | -------------------------- |
@@ -152,14 +153,30 @@ Entries can be either:
152
153
  - A job class identifier (for on-demand jobs)
153
154
  - A `PgBossJobRegistration` object with `job` and `cron` properties (for scheduled jobs)
154
155
 
156
+ ### `PgBossJobRegistration`
157
+
158
+ Configuration object for a scheduled job.
159
+
160
+ | Property | Type | Description |
161
+ | -------- | ------------------ | ---------------------------------------------------------- |
162
+ | `job` | `Identifier<Job>` | The job class identifier to instantiate when the job runs. |
163
+ | `cron` | `string` | A cron expression defining when the job should run. |
164
+
165
+ ### `PgBossJobBroker`
166
+
167
+ Concrete `JobBroker` implementation backed by pg-boss. Constructor signature: `new PgBossJobBroker(registrations: PgBossJobRegistryMap, pgboss: PgBoss)`. Typically resolved through the DI container rather than instantiated directly.
168
+
169
+ ### `PgBossJobRunner`
170
+
171
+ Concrete `JobRunner` implementation backed by pg-boss. Constructor signature: `new PgBossJobRunner(container: Container, registrations: PgBossJobRegistryMap, pgboss: PgBoss, logger: Logger)`. Calls `pgboss.start()` during `start()` and `pgboss.stop()` during `stop()`. Job instances are resolved from the DI container on each invocation. Typically resolved through the DI container rather than instantiated directly.
172
+
155
173
  ## Graceful Shutdown
156
174
 
157
175
  Ensure you stop the runner during application shutdown:
158
176
 
159
177
  ```typescript
160
178
  process.on('SIGTERM', async () => {
161
- await runner.stop();
162
- await pgboss.stop();
179
+ await runner.stop(); // Stops pg-boss internally
163
180
  process.exit(0);
164
181
  });
165
182
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maroonedsoftware/jobbroker",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "A flexible background job processing library with support for scheduled and on-demand jobs.",
5
5
  "author": {
6
6
  "name": "Marooned Software",
@@ -38,8 +38,8 @@
38
38
  "@maroonedsoftware/logger": "1.1.0"
39
39
  },
40
40
  "devDependencies": {
41
- "pg-boss": "^12.15.0",
42
- "@repo/config-eslint": "0.2.0",
41
+ "pg-boss": "^12.18.2",
42
+ "@repo/config-eslint": "0.2.1",
43
43
  "@repo/config-typescript": "0.1.0"
44
44
  },
45
45
  "peerDependencies": {