You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+27Lines changed: 27 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,32 @@
1
1
# cronbake
2
2
3
+
## 0.3.0
4
+
5
+
### Minor Changes
6
+
7
+
- Immediate/delayed first run: Add `immediate` and `delay` options so the first callback can run right away or after a configurable delay (e.g., `"10s"`).
8
+
- Overrun protection: Add `overrunProtection` (default: true) to skip starting a new run if the previous execution is still running; tracks `skippedExecutions` in metrics.
9
+
- Pluggable persistence: Refactor persistence to use providers. Add `FilePersistenceProvider` (JSON on disk) and `RedisPersistenceProvider` (single-key JSON via injected client). New `persistence.strategy` and `persistence.provider` options.
10
+
11
+
### Features
12
+
13
+
- New Cron options: `immediate`, `delay`, `overrunProtection`.
14
+
- New metrics: `skippedExecutions`.
15
+
- New persistence API: `PersistenceProvider` with `save/load` and types for persisted state.
16
+
- Export providers from package API: `FilePersistenceProvider`, `RedisPersistenceProvider`.
17
+
18
+
### Fixes
19
+
20
+
- Parser: Correct `@on_<day>` mapping to Sunday=0…Saturday=6, fix `@every_<n>_months` to run on day 1 (`0 0 0 1 */n *`), and `@every_<n>_dayOfWeek` to `*/n` on day-of-week.
21
+
- Types: Replace `Timer` with `ReturnType<typeof setTimeout|setInterval>` for portability.
22
+
- Build: Replace `@/lib` path aliases in source with relative imports to avoid bundler resolution issues.
23
+
- Packaging: Set `module` to `dist/index.js`, move `@changesets/cli` to devDependencies, ensure Changesets access is public.
24
+
25
+
### Tests
26
+
27
+
- Add tests for immediate/delayed first run and overrun protection.
28
+
- Add provider-focused tests and shared test utilities for persistence (file and Redis via a fake client).
Copy file name to clipboardExpand all lines: README.md
+62-2Lines changed: 62 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,6 +46,11 @@ Cronbake provides two scheduling modes for optimal performance:
46
46
-**Calculated Timeouts** (default): More efficient scheduling using precise timeout calculations
47
47
-**Polling Interval**: Traditional polling-based scheduling with configurable intervals
48
48
49
+
Additional scheduling controls:
50
+
51
+
-**Immediate/Delayed First Run**: Run the first callback immediately (`immediate: true`) or after a delay (`delay: '10s'`).
52
+
-**Overrun Protection**: Skip new starts if a previous run is still executing (`overrunProtection: true`).
53
+
49
54
#### Cron Job Management
50
55
51
56
Cronbake provides a simple and intuitive interface for managing cron jobs. You can easily add, remove, start, stop, pause, resume, and destroy cron jobs using the `Baker` class.
@@ -77,7 +82,7 @@ Track detailed execution history and performance metrics including:
77
82
78
83
Cronbake supports job persistence across application restarts:
79
84
80
-
- Save job state to file system
85
+
- Save job state to file system or Redis (pluggable providers)
#### Immediate/Delayed First Run and Overrun Protection
165
+
166
+
```typescript
167
+
importBakerfrom'cronbake';
168
+
169
+
const baker =Baker.create();
170
+
171
+
baker.add({
172
+
name: 'fast-job',
173
+
cron: '@every_10_seconds',
174
+
immediate: true, // run the first time right away
175
+
delay: '2s', // but wait 2 seconds before that first run
176
+
overrunProtection: true, // skip overlaps if a previous run still executes
177
+
callback: async () => {
178
+
// Do work
179
+
},
180
+
});
181
+
182
+
baker.bakeAll();
183
+
```
184
+
159
185
#### Advanced Configuration
160
186
161
187
You can configure the Baker with advanced options:
@@ -254,6 +280,35 @@ await baker.saveState();
254
280
awaitbaker.restoreState();
255
281
```
256
282
283
+
#### Persistence Providers (File and Redis)
284
+
285
+
Cronbake uses pluggable providers for persistence. A file provider is included by default. A Redis provider is available; you inject your Redis client.
0 commit comments