Skip to content

Commit 757055a

Browse files
committed
docs: update changelog for latest runtime changes
1 parent d437182 commit 757055a

5 files changed

Lines changed: 142 additions & 41 deletions

File tree

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Adapter-Aware Workers and Schedules
2+
3+
## New Features
4+
5+
### Select an Adapter per Worker
6+
7+
Workers can now listen on a specific registered Adapter with `worker.adapter`. When omitted, the
8+
worker continues to use the queue manager's default Adapter.
9+
10+
```typescript
11+
const config = {
12+
default: 'redis',
13+
adapters: {
14+
redis: redis(redisConfig),
15+
database: knex(databaseConfig),
16+
},
17+
worker: {
18+
adapter: 'database',
19+
concurrency: 5,
20+
},
21+
}
22+
23+
const worker = new Worker(config)
24+
await worker.start(['default', 'emails'])
25+
```
26+
27+
This makes it possible to run separate workers for queues stored by different Adapters.
28+
29+
### Store and Access Schedules on a Specific Adapter
30+
31+
Schedules can now select their owning Adapter with `.with()`:
32+
33+
```typescript
34+
await CleanupJob.schedule({ days: 30 }).id('daily-cleanup').with('redis').cron('0 0 * * *')
35+
```
36+
37+
`Schedule.find()` and `Schedule.list()` accept an Adapter selector when accessing schedules outside
38+
the default Adapter:
39+
40+
```typescript
41+
const schedule = await Schedule.find('daily-cleanup', { adapter: 'redis' })
42+
const schedules = await Schedule.list({ status: 'active' }, { adapter: 'redis' })
43+
```
44+
45+
A returned `Schedule` retains the selected Adapter for subsequent `pause()`, `resume()`, `delete()`,
46+
and `trigger()` calls. Jobs dispatched by a schedule stay on the Adapter that owns that schedule.
47+
48+
### Identify Jobs Dispatched by a Schedule
49+
50+
Scheduled jobs now include their originating schedule ID in `JobData.scheduleId`. Jobs can access it
51+
while executing through `this.context.scheduleId`:
52+
53+
```typescript
54+
async execute() {
55+
console.log(this.context.scheduleId)
56+
}
57+
```
58+
59+
The value is `undefined` for jobs that were not dispatched by a schedule.
60+
61+
## Upgrade Notes
62+
63+
Start a Worker for every Adapter that owns schedules. A Worker only claims schedules and jobs from
64+
its configured Adapter.
65+
66+
When a schedule does not call `.with()`, its Adapter is resolved from the job's `adapter` option,
67+
then from the Adapter configured for the job's queue, and finally from the queue manager default.
68+
An explicit `.with()` always takes precedence.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Consistent Job Dispatch and Execution
2+
3+
## Improvements
4+
5+
All job dispatch paths now apply the same routing and job options. This includes `dispatch()`,
6+
`dispatchMany()`, manual schedule triggers, and schedules claimed by workers.
7+
8+
The routing order is now consistent across these paths:
9+
10+
1. Fluent overrides such as `.toQueue()` and `.with()`
11+
2. Static `Job.options`
12+
3. The Adapter configured for the selected queue
13+
4. The queue manager's default Adapter
14+
15+
Queue, Adapter, priority, custom job name, creation timestamp, and schedule provenance are therefore
16+
preserved consistently regardless of how a job is dispatched. Static job options are resolved when
17+
the fluent builder runs, so changes made between builder creation and execution are applied.
18+
19+
The Sync adapter and Worker execution paths now also share the same job lifecycle behavior,
20+
including context construction, dependency injection through `jobFactory`, execution wrappers,
21+
timeouts, retries, failed hooks, and tracing.
22+
23+
## Upgrade Notes
24+
25+
A job routed to a queue with `queues.<name>.adapter` now uses that Adapter when neither `.with()` nor
26+
`Job.options.adapter` selects another one. Previously, some dispatch paths could incorrectly fall
27+
back to the queue manager's default Adapter. Verify that a Worker is running for every Adapter used
28+
by queue configuration.
29+
30+
Explicit fluent options continue to take precedence over static job options.

.changelog/hot-reloading-jobs.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Hot Reloading Jobs
2+
3+
## New Feature
4+
5+
Workers can now execute the latest saved version of a job without restarting during development.
6+
7+
Enable `hotReload` when initializing the queue manager. Jobs discovered from `locations` will then
8+
be resolved from their module again before every execution.
9+
10+
```typescript
11+
await QueueManager.init({
12+
default: 'redis',
13+
adapters: {
14+
redis: redis({ host: 'localhost', port: 6379 }),
15+
},
16+
locations: ['./app/jobs/**/*.ts'],
17+
hotReload: process.env.NODE_ENV === 'development',
18+
})
19+
```
20+
21+
Hot reload integrates with [Hot Hook](https://github.com/Julien-R44/hot-hook). The queue provides
22+
the dynamic import boundary, while the application remains responsible for installing and
23+
initializing Hot Hook. AdonisJS applications can use `node ace serve --hmr`; standalone worker
24+
processes must initialize Hot Hook themselves.
25+
26+
`Locator.registerFromGlob()` also accepts the option directly:
27+
28+
```typescript
29+
await Locator.registerFromGlob(['./app/jobs/**/*.ts'], { hotReload: true })
30+
```
31+
32+
## Upgrade Notes
33+
34+
Hot reload is disabled by default and should only be enabled in development.
35+
36+
Only jobs discovered from `locations` or registered with `Locator.registerFromGlob()` can be
37+
reloaded. Jobs registered manually with `Locator.register()` do not have a module path to reload.
38+
39+
Changes to the set of registered jobs still require a restart. This includes adding, deleting,
40+
moving, or renaming a job, as well as changing its configured `name`. A job that is already running
41+
keeps its current implementation; the next execution receives the updated version.
42+
43+
Avoid import-time side effects in hot-reloaded job modules, since their module code can execute
44+
again after an invalidation.

.changelog/job-deduplication.md

Lines changed: 0 additions & 26 deletions
This file was deleted.

.changelog/redis-empty-array-payloads.md

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)