flowli 0.2.2 → 0.3.0
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.
- package/README.md +6 -0
- package/dist/core/types.d.ts +14 -1
- package/dist/index.d.ts +1 -1
- package/dist/runner/types.d.ts +1 -0
- package/jsr.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -427,6 +427,12 @@ Flowli supports:
|
|
|
427
427
|
|
|
428
428
|
The job definitions stay the same. Only the driver changes.
|
|
429
429
|
|
|
430
|
+
Retry defaults can be attached globally or per job, including:
|
|
431
|
+
|
|
432
|
+
- `fixed` and `exponential` backoff
|
|
433
|
+
- capped retries with `maxDelayMs`
|
|
434
|
+
- jitter to spread retry bursts
|
|
435
|
+
|
|
430
436
|
## Runner
|
|
431
437
|
|
|
432
438
|
The runner is explicit and secondary by design.
|
package/dist/core/types.d.ts
CHANGED
|
@@ -31,9 +31,15 @@ export interface JobDefaults {
|
|
|
31
31
|
readonly maxAttempts?: number;
|
|
32
32
|
readonly backoff?: BackoffOptions;
|
|
33
33
|
}
|
|
34
|
+
export interface BackoffJitterOptions {
|
|
35
|
+
readonly minRatio: number;
|
|
36
|
+
readonly maxRatio: number;
|
|
37
|
+
}
|
|
34
38
|
export interface BackoffOptions {
|
|
35
39
|
readonly type: "fixed" | "exponential";
|
|
36
40
|
readonly delayMs: number;
|
|
41
|
+
readonly maxDelayMs?: number;
|
|
42
|
+
readonly jitter?: boolean | BackoffJitterOptions;
|
|
37
43
|
}
|
|
38
44
|
export interface FlowliInvocationOptions<TMeta> {
|
|
39
45
|
readonly meta?: TMeta;
|
|
@@ -99,7 +105,7 @@ export interface FlowliDriver {
|
|
|
99
105
|
acquireNextReady(now: number, leaseMs: number): Promise<AcquiredJobRecord | null>;
|
|
100
106
|
renewLease(jobId: string, token: string, leaseMs: number): Promise<boolean>;
|
|
101
107
|
markCompleted(acquired: AcquiredJobRecord, finishedAt: number): Promise<void>;
|
|
102
|
-
markFailed(acquired: AcquiredJobRecord, finishedAt: number, error: PersistedJobError): Promise<
|
|
108
|
+
markFailed(acquired: AcquiredJobRecord, finishedAt: number, error: PersistedJobError): Promise<MarkFailedResult>;
|
|
103
109
|
materializeDueSchedules(now: number, leaseMs: number): Promise<number>;
|
|
104
110
|
}
|
|
105
111
|
export interface DefineJobsOptions<TJobs extends JobsRecord, TContext extends FlowliContextRecord> {
|
|
@@ -153,9 +159,16 @@ export interface PersistedJobRecord {
|
|
|
153
159
|
readonly updatedAt: number;
|
|
154
160
|
readonly scheduledFor: number;
|
|
155
161
|
readonly attemptsMade: number;
|
|
162
|
+
readonly failureCount: number;
|
|
156
163
|
readonly maxAttempts: number;
|
|
157
164
|
readonly backoff?: BackoffOptions;
|
|
158
165
|
readonly lastError?: PersistedJobError;
|
|
166
|
+
readonly lastFailedAt?: number;
|
|
167
|
+
readonly nextRetryAt?: number;
|
|
168
|
+
}
|
|
169
|
+
export interface MarkFailedResult {
|
|
170
|
+
readonly state: "failed" | "retrying";
|
|
171
|
+
readonly retryAt?: number;
|
|
159
172
|
}
|
|
160
173
|
export interface AcquiredJobRecord {
|
|
161
174
|
readonly token: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { defineJobs } from "./core/define-jobs.js";
|
|
2
2
|
export { FlowliDefinitionError, FlowliDriverError, FlowliError, FlowliSchedulingError, FlowliStrategyError, FlowliValidationError, } from "./core/errors.js";
|
|
3
3
|
export { createContextualJobFactory, job } from "./core/job.js";
|
|
4
|
-
export type { BackoffOptions, DefineJobsBuilder, DelayValue, FlowliContextRecord, FlowliContextResolver, FlowliDriver, FlowliInvocationOptions, FlowliJobSurface, FlowliRuntime, JobDefaults, JobDefinition, JobHandlerArgs, JobReceipt, ScheduleInvocation, ScheduleReceipt, StandardSchemaIssue, StandardSchemaV1, } from "./core/types.js";
|
|
4
|
+
export type { BackoffJitterOptions, BackoffOptions, DefineJobsBuilder, DelayValue, FlowliContextRecord, FlowliContextResolver, FlowliDriver, FlowliInvocationOptions, FlowliJobSurface, FlowliRuntime, JobDefaults, JobDefinition, JobHandlerArgs, JobReceipt, ScheduleInvocation, ScheduleReceipt, StandardSchemaIssue, StandardSchemaV1, } from "./core/types.js";
|
package/dist/runner/types.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export interface RunnerHooks {
|
|
|
3
3
|
readonly onJobStarted?: (jobId: string, jobName: string) => void | Promise<void>;
|
|
4
4
|
readonly onJobCompleted?: (jobId: string, jobName: string) => void | Promise<void>;
|
|
5
5
|
readonly onJobFailed?: (jobId: string, jobName: string, error: PersistedJobError) => void | Promise<void>;
|
|
6
|
+
readonly onJobRetryScheduled?: (jobId: string, jobName: string, retryAt: number, error: PersistedJobError) => void | Promise<void>;
|
|
6
7
|
}
|
|
7
8
|
export interface RunnerOptions<TJobs extends JobsRecord, TContext extends FlowliContextRecord> {
|
|
8
9
|
readonly flowli: FlowliRuntime<TJobs, TContext>;
|
package/jsr.json
CHANGED
package/package.json
CHANGED