@spooled/sdk 1.0.33 → 1.0.34
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/dist/{index-QIsnz4Bc.d.cts → index-CYEamGDj.d.cts} +25 -0
- package/dist/{index-QIsnz4Bc.d.ts → index-CYEamGDj.d.ts} +25 -0
- package/dist/index.cjs +8 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +8 -4
- package/dist/index.js.map +1 -1
- package/dist/worker/index.cjs +8 -4
- package/dist/worker/index.cjs.map +1 -1
- package/dist/worker/index.d.cts +1 -1
- package/dist/worker/index.d.ts +1 -1
- package/dist/worker/index.js +8 -4
- package/dist/worker/index.js.map +1 -1
- package/package.json +1 -1
- package/proto/spooled.proto +13 -0
|
@@ -647,6 +647,13 @@ interface ClaimedJob {
|
|
|
647
647
|
maxRetries: number;
|
|
648
648
|
timeoutSeconds: number;
|
|
649
649
|
leaseExpiresAt?: string;
|
|
650
|
+
/**
|
|
651
|
+
* Lease fencing token for this claim. Echo it back on
|
|
652
|
+
* complete/fail/heartbeat so the operation applies only to the lease this
|
|
653
|
+
* worker actually holds (backend rejects stale leases with 409
|
|
654
|
+
* LEASE_EXPIRED). Omitted = legacy behavior.
|
|
655
|
+
*/
|
|
656
|
+
leaseId?: string;
|
|
650
657
|
}
|
|
651
658
|
/** Parameters for claiming jobs */
|
|
652
659
|
interface ClaimJobsParams {
|
|
@@ -669,6 +676,8 @@ interface CompleteJobParams {
|
|
|
669
676
|
workerId: string;
|
|
670
677
|
/** Optional result payload */
|
|
671
678
|
result?: JsonObject;
|
|
679
|
+
/** Lease fencing token from the claimed job (rejects stale leases when set) */
|
|
680
|
+
leaseId?: string;
|
|
672
681
|
}
|
|
673
682
|
/** Parameters for failing a job */
|
|
674
683
|
interface FailJobParams {
|
|
@@ -676,6 +685,8 @@ interface FailJobParams {
|
|
|
676
685
|
workerId: string;
|
|
677
686
|
/** Error message (1-2048 chars) */
|
|
678
687
|
error: string;
|
|
688
|
+
/** Lease fencing token from the claimed job (rejects stale leases when set) */
|
|
689
|
+
leaseId?: string;
|
|
679
690
|
}
|
|
680
691
|
/** Parameters for job heartbeat */
|
|
681
692
|
interface HeartbeatJobParams {
|
|
@@ -683,6 +694,8 @@ interface HeartbeatJobParams {
|
|
|
683
694
|
workerId: string;
|
|
684
695
|
/** Lease duration in seconds (5-3600) */
|
|
685
696
|
leaseDurationSecs: number;
|
|
697
|
+
/** Lease fencing token from the claimed job (rejects stale leases when set) */
|
|
698
|
+
leaseId?: string;
|
|
686
699
|
}
|
|
687
700
|
/** Response for priority boost */
|
|
688
701
|
interface BoostPriorityResponse {
|
|
@@ -2602,6 +2615,12 @@ interface GrpcJob {
|
|
|
2602
2615
|
leaseExpiresAt?: GrpcTimestamp | string | null;
|
|
2603
2616
|
assignedWorkerId?: string | null;
|
|
2604
2617
|
idempotencyKey?: string | null;
|
|
2618
|
+
/**
|
|
2619
|
+
* Lease fencing token (proto `lease_id`). Returned on dequeue; echo it back
|
|
2620
|
+
* in Complete/Fail/RenewLease so the operation applies only to the lease
|
|
2621
|
+
* this worker actually holds (empty = legacy worker_id fence).
|
|
2622
|
+
*/
|
|
2623
|
+
leaseId?: string;
|
|
2605
2624
|
}
|
|
2606
2625
|
/** Enqueue request */
|
|
2607
2626
|
interface GrpcEnqueueRequest {
|
|
@@ -2637,6 +2656,8 @@ interface GrpcCompleteRequest {
|
|
|
2637
2656
|
workerId: string;
|
|
2638
2657
|
/** Result as object (will be converted to google.protobuf.Struct) */
|
|
2639
2658
|
result?: Record<string, unknown>;
|
|
2659
|
+
/** Lease fencing token from the dequeued job (proto `lease_id`) */
|
|
2660
|
+
leaseId?: string;
|
|
2640
2661
|
}
|
|
2641
2662
|
/** Complete response */
|
|
2642
2663
|
interface GrpcCompleteResponse {
|
|
@@ -2648,6 +2669,8 @@ interface GrpcFailRequest {
|
|
|
2648
2669
|
workerId: string;
|
|
2649
2670
|
error: string;
|
|
2650
2671
|
retry?: boolean;
|
|
2672
|
+
/** Lease fencing token from the dequeued job (proto `lease_id`) */
|
|
2673
|
+
leaseId?: string;
|
|
2651
2674
|
}
|
|
2652
2675
|
/** Fail response */
|
|
2653
2676
|
interface GrpcFailResponse {
|
|
@@ -2660,6 +2683,8 @@ interface GrpcRenewLeaseRequest {
|
|
|
2660
2683
|
jobId: string;
|
|
2661
2684
|
workerId: string;
|
|
2662
2685
|
extensionSecs: number;
|
|
2686
|
+
/** Lease fencing token from the dequeued job (proto `lease_id`) */
|
|
2687
|
+
leaseId?: string;
|
|
2663
2688
|
}
|
|
2664
2689
|
/** Renew lease response */
|
|
2665
2690
|
interface GrpcRenewLeaseResponse {
|
|
@@ -647,6 +647,13 @@ interface ClaimedJob {
|
|
|
647
647
|
maxRetries: number;
|
|
648
648
|
timeoutSeconds: number;
|
|
649
649
|
leaseExpiresAt?: string;
|
|
650
|
+
/**
|
|
651
|
+
* Lease fencing token for this claim. Echo it back on
|
|
652
|
+
* complete/fail/heartbeat so the operation applies only to the lease this
|
|
653
|
+
* worker actually holds (backend rejects stale leases with 409
|
|
654
|
+
* LEASE_EXPIRED). Omitted = legacy behavior.
|
|
655
|
+
*/
|
|
656
|
+
leaseId?: string;
|
|
650
657
|
}
|
|
651
658
|
/** Parameters for claiming jobs */
|
|
652
659
|
interface ClaimJobsParams {
|
|
@@ -669,6 +676,8 @@ interface CompleteJobParams {
|
|
|
669
676
|
workerId: string;
|
|
670
677
|
/** Optional result payload */
|
|
671
678
|
result?: JsonObject;
|
|
679
|
+
/** Lease fencing token from the claimed job (rejects stale leases when set) */
|
|
680
|
+
leaseId?: string;
|
|
672
681
|
}
|
|
673
682
|
/** Parameters for failing a job */
|
|
674
683
|
interface FailJobParams {
|
|
@@ -676,6 +685,8 @@ interface FailJobParams {
|
|
|
676
685
|
workerId: string;
|
|
677
686
|
/** Error message (1-2048 chars) */
|
|
678
687
|
error: string;
|
|
688
|
+
/** Lease fencing token from the claimed job (rejects stale leases when set) */
|
|
689
|
+
leaseId?: string;
|
|
679
690
|
}
|
|
680
691
|
/** Parameters for job heartbeat */
|
|
681
692
|
interface HeartbeatJobParams {
|
|
@@ -683,6 +694,8 @@ interface HeartbeatJobParams {
|
|
|
683
694
|
workerId: string;
|
|
684
695
|
/** Lease duration in seconds (5-3600) */
|
|
685
696
|
leaseDurationSecs: number;
|
|
697
|
+
/** Lease fencing token from the claimed job (rejects stale leases when set) */
|
|
698
|
+
leaseId?: string;
|
|
686
699
|
}
|
|
687
700
|
/** Response for priority boost */
|
|
688
701
|
interface BoostPriorityResponse {
|
|
@@ -2602,6 +2615,12 @@ interface GrpcJob {
|
|
|
2602
2615
|
leaseExpiresAt?: GrpcTimestamp | string | null;
|
|
2603
2616
|
assignedWorkerId?: string | null;
|
|
2604
2617
|
idempotencyKey?: string | null;
|
|
2618
|
+
/**
|
|
2619
|
+
* Lease fencing token (proto `lease_id`). Returned on dequeue; echo it back
|
|
2620
|
+
* in Complete/Fail/RenewLease so the operation applies only to the lease
|
|
2621
|
+
* this worker actually holds (empty = legacy worker_id fence).
|
|
2622
|
+
*/
|
|
2623
|
+
leaseId?: string;
|
|
2605
2624
|
}
|
|
2606
2625
|
/** Enqueue request */
|
|
2607
2626
|
interface GrpcEnqueueRequest {
|
|
@@ -2637,6 +2656,8 @@ interface GrpcCompleteRequest {
|
|
|
2637
2656
|
workerId: string;
|
|
2638
2657
|
/** Result as object (will be converted to google.protobuf.Struct) */
|
|
2639
2658
|
result?: Record<string, unknown>;
|
|
2659
|
+
/** Lease fencing token from the dequeued job (proto `lease_id`) */
|
|
2660
|
+
leaseId?: string;
|
|
2640
2661
|
}
|
|
2641
2662
|
/** Complete response */
|
|
2642
2663
|
interface GrpcCompleteResponse {
|
|
@@ -2648,6 +2669,8 @@ interface GrpcFailRequest {
|
|
|
2648
2669
|
workerId: string;
|
|
2649
2670
|
error: string;
|
|
2650
2671
|
retry?: boolean;
|
|
2672
|
+
/** Lease fencing token from the dequeued job (proto `lease_id`) */
|
|
2673
|
+
leaseId?: string;
|
|
2651
2674
|
}
|
|
2652
2675
|
/** Fail response */
|
|
2653
2676
|
interface GrpcFailResponse {
|
|
@@ -2660,6 +2683,8 @@ interface GrpcRenewLeaseRequest {
|
|
|
2660
2683
|
jobId: string;
|
|
2661
2684
|
workerId: string;
|
|
2662
2685
|
extensionSecs: number;
|
|
2686
|
+
/** Lease fencing token from the dequeued job (proto `lease_id`) */
|
|
2687
|
+
leaseId?: string;
|
|
2663
2688
|
}
|
|
2664
2689
|
/** Renew lease response */
|
|
2665
2690
|
interface GrpcRenewLeaseResponse {
|
package/dist/index.cjs
CHANGED
|
@@ -3288,7 +3288,7 @@ var SpooledWorker = class {
|
|
|
3288
3288
|
...DEFAULT_OPTIONS,
|
|
3289
3289
|
hostname: os.hostname(),
|
|
3290
3290
|
workerType: "nodejs",
|
|
3291
|
-
version: "1.0.
|
|
3291
|
+
version: "1.0.34",
|
|
3292
3292
|
metadata: {},
|
|
3293
3293
|
...options
|
|
3294
3294
|
};
|
|
@@ -3533,7 +3533,8 @@ var SpooledWorker = class {
|
|
|
3533
3533
|
try {
|
|
3534
3534
|
await this.client.jobs.complete(job.id, {
|
|
3535
3535
|
workerId: this.workerId,
|
|
3536
|
-
result
|
|
3536
|
+
result,
|
|
3537
|
+
...job.leaseId !== void 0 && { leaseId: job.leaseId }
|
|
3537
3538
|
});
|
|
3538
3539
|
this.emit("job:completed", {
|
|
3539
3540
|
jobId: job.id,
|
|
@@ -3550,7 +3551,8 @@ var SpooledWorker = class {
|
|
|
3550
3551
|
try {
|
|
3551
3552
|
await this.client.jobs.fail(job.id, {
|
|
3552
3553
|
workerId: this.workerId,
|
|
3553
|
-
error: errorMessage
|
|
3554
|
+
error: errorMessage,
|
|
3555
|
+
...job.leaseId !== void 0 && { leaseId: job.leaseId }
|
|
3554
3556
|
});
|
|
3555
3557
|
this.emit("job:failed", {
|
|
3556
3558
|
jobId: job.id,
|
|
@@ -3571,10 +3573,12 @@ var SpooledWorker = class {
|
|
|
3571
3573
|
}
|
|
3572
3574
|
async sendJobHeartbeat(jobId) {
|
|
3573
3575
|
if (!this.workerId) return;
|
|
3576
|
+
const leaseId = this.activeJobs.get(jobId)?.job.leaseId;
|
|
3574
3577
|
try {
|
|
3575
3578
|
await this.client.jobs.heartbeat(jobId, {
|
|
3576
3579
|
workerId: this.workerId,
|
|
3577
|
-
leaseDurationSecs: this.options.leaseDuration
|
|
3580
|
+
leaseDurationSecs: this.options.leaseDuration,
|
|
3581
|
+
...leaseId !== void 0 && { leaseId }
|
|
3578
3582
|
});
|
|
3579
3583
|
} catch (error) {
|
|
3580
3584
|
this.debug(`Job heartbeat failed for ${jobId}`, error);
|