@xeonr/pipelines-sdk 0.1.0 → 0.2.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.
Files changed (48) hide show
  1. package/README.md +89 -22
  2. package/dist/client.d.ts +11 -0
  3. package/dist/client.d.ts.map +1 -1
  4. package/dist/client.js +5 -0
  5. package/dist/client.js.map +1 -1
  6. package/dist/errors.d.ts +42 -6
  7. package/dist/errors.d.ts.map +1 -1
  8. package/dist/errors.js +45 -2
  9. package/dist/errors.js.map +1 -1
  10. package/dist/gen/xeonr/pipelines/private/v1/worker_pb.d.ts +159 -13
  11. package/dist/gen/xeonr/pipelines/private/v1/worker_pb.d.ts.map +1 -1
  12. package/dist/gen/xeonr/pipelines/private/v1/worker_pb.js +70 -8
  13. package/dist/gen/xeonr/pipelines/private/v1/worker_pb.js.map +1 -1
  14. package/dist/gen/xeonr/pipelines/v1/common_pb.d.ts +34 -4
  15. package/dist/gen/xeonr/pipelines/v1/common_pb.d.ts.map +1 -1
  16. package/dist/gen/xeonr/pipelines/v1/common_pb.js +33 -3
  17. package/dist/gen/xeonr/pipelines/v1/common_pb.js.map +1 -1
  18. package/dist/gen/xeonr/pipelines/v1/definition_pb.d.ts +3 -1
  19. package/dist/gen/xeonr/pipelines/v1/definition_pb.d.ts.map +1 -1
  20. package/dist/gen/xeonr/pipelines/v1/definition_pb.js.map +1 -1
  21. package/dist/gen/xeonr/pipelines/v1/pools_pb.d.ts +120 -1
  22. package/dist/gen/xeonr/pipelines/v1/pools_pb.d.ts.map +1 -1
  23. package/dist/gen/xeonr/pipelines/v1/pools_pb.js +36 -11
  24. package/dist/gen/xeonr/pipelines/v1/pools_pb.js.map +1 -1
  25. package/dist/gen/xeonr/pipelines/v1/runs_pb.d.ts +21 -1
  26. package/dist/gen/xeonr/pipelines/v1/runs_pb.d.ts.map +1 -1
  27. package/dist/gen/xeonr/pipelines/v1/runs_pb.js +1 -1
  28. package/dist/gen/xeonr/pipelines/v1/runs_pb.js.map +1 -1
  29. package/dist/gen/xeonr/pipelines/v1/secrets_pb.d.ts +8 -3
  30. package/dist/gen/xeonr/pipelines/v1/secrets_pb.d.ts.map +1 -1
  31. package/dist/gen/xeonr/pipelines/v1/secrets_pb.js.map +1 -1
  32. package/dist/index.d.ts +2 -1
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +2 -1
  35. package/dist/index.js.map +1 -1
  36. package/dist/logship.d.ts +60 -10
  37. package/dist/logship.d.ts.map +1 -1
  38. package/dist/logship.js +171 -28
  39. package/dist/logship.js.map +1 -1
  40. package/dist/testing/index.d.ts +14 -1
  41. package/dist/testing/index.d.ts.map +1 -1
  42. package/dist/testing/index.js +134 -28
  43. package/dist/testing/index.js.map +1 -1
  44. package/dist/worker.d.ts +30 -7
  45. package/dist/worker.d.ts.map +1 -1
  46. package/dist/worker.js +96 -27
  47. package/dist/worker.js.map +1 -1
  48. package/package.json +1 -1
package/README.md CHANGED
@@ -94,7 +94,10 @@ Pass `register: false` and `pool.id` if something else does that.
94
94
 
95
95
  1. **Claim.** It long-polls `ClaimAttempts` for its handlers. No claim is
96
96
  allowed to push the worker past its overall `concurrency` or a handler's
97
- `concurrency`: each poll reserves its slots up front.
97
+ `concurrency`: each poll reserves its slots up front. Each `Worker` has
98
+ its own instance id (`worker.workerId`, a UUID), which it claims with
99
+ and echoes in `AttemptRef.worker_id` on every later call, so one
100
+ replica cannot write to another's attempt.
98
101
  2. **Start.** It calls `StartAttempt`. Your code runs only after that succeeds.
99
102
  3. **Heartbeat.** It renews the lease at the interval the claim gives, from
100
103
  the claim until completion.
@@ -105,25 +108,46 @@ Pass `register: false` and `pool.id` if something else does that.
105
108
  - `lost`: the lease was lost;
106
109
  - `shutdown`: `stop()` ran past its timeout.
107
110
  5. **Log.** `ctx.log` ships the attempt's log in order with `AppendLogs`,
108
- idempotent on seq, and honours the attempt's log cap.
111
+ idempotent on seq, and honours the attempt's log cap. If the server lost
112
+ chunks it had acknowledged, it says so with `out_of_range` naming the seq
113
+ it expects: the worker resends from there if it still holds them, and
114
+ otherwise carries on from that seq after one line saying how many bytes
115
+ of output were lost.
109
116
  6. **Complete.** It calls `CompleteAttempt` with the kv outputs inline, or
110
117
  with a termination:
111
118
 
112
119
  | How the handler ended | Termination | Failure class (set by the platform) |
113
120
  |---|---|---|
114
121
  | Returned outputs | `EXITED` (0) | none |
115
- | Threw or rejected; outputs not valid kv; `parseInput` threw | `HANDLER_ERROR` | `HANDLER_ERROR` |
122
+ | Threw or rejected; `parseInput` threw | `HANDLER_ERROR`, kind from the error (below) | `HANDLER_ERROR` |
123
+ | Returned outputs that are not valid kv | `HANDLER_ERROR`, kind `PERMANENT` | `HANDLER_ERROR` |
116
124
  | Still running at its deadline | `TIMED_OUT` | `TIMEOUT` |
117
125
  | Stopped after a cancel | `CANCELLED` | `CANCELLED` |
118
- | Aborted by `stop()` past its timeout | `RUNNER_ERROR` | `RUNNER_CRASHED` |
126
+ | Aborted by `stop()` past its timeout | `INTERRUPTED` | `INTERRUPTED` |
119
127
  | Lease lost | nothing reported | `ABANDONED`, decided by the platform |
120
128
 
121
129
  The platform picks the failure class and decides whether to retry, using the
122
130
  node's `retry.when`. By default it retries only transient classes:
123
- `ABANDONED`, `RUNNER_CRASHED`, `IMAGE_PULL`, `STAGING_FAILED` and `INTERNAL`.
124
- So a handler error is retried only when the node lists `HANDLER_ERROR`. A
125
- handler cannot mark one particular error as permanent or transient: the
126
- contract has no field for it (see "Contract gaps" in the MR).
131
+ `ABANDONED`, `RUNNER_CRASHED`, `IMAGE_PULL`, `STAGING_FAILED`, `INTERRUPTED`
132
+ and `INTERNAL`.
133
+
134
+ A handler says whether its failure can pass by what it throws. The class
135
+ stays `HANDLER_ERROR` either way; this sets
136
+ `CompleteAttemptRequest.handler_failure_kind`:
137
+
138
+ ```ts
139
+ import { PermanentError, TransientError } from "@xeonr/pipelines-sdk";
140
+
141
+ if (res.status === 503) throw new TransientError("mail service unavailable"); // retried under the default policy
142
+ if (res.status === 422) throw new PermanentError("template not found"); // never retried, whatever retry.when says
143
+ throw new Error("anything else"); // unspecified: retry.when alone decides
144
+ ```
145
+
146
+ The marker is found on the thrown error or anywhere in its `cause` chain, so
147
+ wrapping one (`new Error("send failed", { cause: new PermanentError(...) })`)
148
+ keeps it. A worker can narrow a node's policy this way, never widen it: an
149
+ explicit `retry.when` still applies to a `TransientError`, and `retry.max`
150
+ and backoff bound every retry.
127
151
 
128
152
  A thrown error or rejected promise fails that attempt, never the process.
129
153
  JavaScript cannot kill a handler that ignores its signal. Such a handler gets
@@ -140,8 +164,10 @@ The worker reads each error by its Connect code (`errorKind`):
140
164
  retried.
141
165
  - `unauthenticated` or `permission_denied`: not transient. The worker stops
142
166
  claiming, calls `onError`, and `wait()` rejects once in-flight attempts end.
143
- - `out_of_range` on `AppendLogs`: not fatal. The rest of that attempt's log is
144
- dropped and the attempt carries on.
167
+ - `out_of_range` on `AppendLogs`: not fatal. It names the seq the server
168
+ expects, and the log resends or renumbers from there (see step 5). An
169
+ `out_of_range` that names no seq drops the rest of that attempt's log; the
170
+ attempt carries on.
145
171
  - Anything else (`unavailable`, `deadline_exceeded`, `internal`, network
146
172
  errors): retried with backoff. A heartbeat that cannot get through before
147
173
  the lease runs out loses the attempt.
@@ -151,13 +177,17 @@ The worker reads each error by its Connect code (`errorKind`):
151
177
  `stop({ timeoutMs, graceMs })` works in four steps:
152
178
 
153
179
  1. It stops claiming and aborts any held long-polls.
154
- 2. In-flight handlers get `timeoutMs` to finish (default 30 s). Their real
180
+ 2. Attempts that were claimed but never started are handed back with
181
+ `ReleaseAttempt`. They are offered again at once, to any worker, as the
182
+ same attempt, with nothing spent. A release answered `failed_precondition`
183
+ was no longer this worker's, which counts as done.
184
+ 3. Running handlers get `timeoutMs` to finish (default 30 s). Their real
155
185
  outcome is reported.
156
- 3. Handlers still running after that are aborted with `shutdown`. They get
157
- `graceMs` more (default 5 s), then their attempts are completed as
158
- `RUNNER_ERROR`, which the platform retries by default.
159
- 4. Attempts that were claimed but never started are left alone. Their leases
160
- lapse and they are offered again with no retry spent.
186
+ 4. Handlers still running after that are aborted with `shutdown`. They get
187
+ `graceMs` more (default 5 s), then their attempts are completed with
188
+ `TERMINATION_INTERRUPTED`. That is transient, so the platform retries it by
189
+ default. On a node marked `interruptible`, the retry does not count
190
+ against `retry.max`.
161
191
 
162
192
  ## Enqueue jobs and start runs
163
193
 
@@ -173,6 +203,8 @@ const { run } = await pipelines.createJob({
173
203
  payload: { to: "ada@example.com", template: "welcome" },
174
204
  idempotencyKey: "welcome-email:user-4821",
175
205
  delayMs: 10 * 60_000, // not offered to a worker before ten minutes have passed
206
+ retry: { max: 3, when: [FailureClass.HANDLER_ERROR] }, // the job's node policy; unset is the platform default
207
+ timeoutMs: 5 * 60_000, // bounds one attempt
176
208
  });
177
209
 
178
210
  // A full run that mixes an image node and a worker node, passing an output between them.
@@ -186,6 +218,7 @@ await pipelines.createRun({
186
218
  {
187
219
  id: "notify",
188
220
  action: { case: "handler", value: "acme/send-email" },
221
+ needs: [{ node: "extract" }], // a reference adds no edge: name the node in needs
189
222
  with: { to: { kind: { case: "stringValue", value: "${{ steps.extract.outputs.kv.owner }}" } } },
190
223
  retry: { max: 3, when: [FailureClass.HANDLER_ERROR] },
191
224
  },
@@ -228,17 +261,51 @@ The fake models:
228
261
 
229
262
  - accounts (a token with a tenant and scopes), and namespace and pool
230
263
  ownership;
231
- - publish, pools, jobs with delay and idempotency, and runs;
232
- - the claim long-poll, leases and their lapse (`expireLease`), heartbeats and
233
- cancel;
234
- - logs, with `out_of_range` for a gap;
235
- - the server's mapping from termination to failure class, and retries by
236
- class;
264
+ - publish, pools, jobs with delay, idempotency, retry and timeout, and runs
265
+ (references only into a node's needs closure);
266
+ - the claim long-poll, the worker id on every ref, leases and their lapse
267
+ (`expireLease`), `ReleaseAttempt`, heartbeats and cancel;
268
+ - logs, with `out_of_range` naming the expected seq for a gap, and
269
+ `loseLogChunks` to play a server that lost acknowledged chunks;
270
+ - the server's mapping from termination to failure class,
271
+ `handler_failure_kind`, retries by class, and free interruptions on an
272
+ `interruptible` node;
237
273
  - external (image) nodes you settle with `completeNode`;
238
274
  - error injection (`inject("Heartbeat", Code.Unavailable, 2)`).
239
275
 
240
276
  It does not model secrets, blobs, tiers or routing between pools.
241
277
 
278
+ ## Conformance suite
279
+
280
+ `src/conformance/suite.ts` holds the cases both SDKs must pass against
281
+ pipelines-api. The Go SDK runs the same list (`xeonr/pipelines/sdk-go`,
282
+ `CONFORMANCE.md`):
283
+
284
+ 1. enqueue
285
+ 2. delayed job
286
+ 3. retry by class
287
+ 4. permanent failure
288
+ 5. cancel
289
+ 6. lease loss
290
+ 7. release on shutdown
291
+ 8. another owner's handler unclaimable
292
+
293
+ The cases run against the fake in every `pnpm test`. To run them against a
294
+ real pipelines-api, set these variables (otherwise the suite is skipped):
295
+
296
+ | Variable | Value |
297
+ |---|---|
298
+ | `PIPELINES_API_URL` | the api's base URL |
299
+ | `PIPELINES_TOKEN` | an access token; or `PIPELINES_SA_ASSERTION` with `PIPELINES_TOKEN_URL` |
300
+ | `PIPELINES_TENANT` | the owner's team URN |
301
+ | `PIPELINES_NAMESPACE` | a registry namespace that team owns |
302
+ | `PIPELINES_OTHER_TOKEN`, `PIPELINES_OTHER_TENANT` | optional: a second product, for the ownership case |
303
+ | `PIPELINES_LEASE_MS` | optional: the server's lease, default 60000 |
304
+
305
+ ```sh
306
+ PIPELINES_API_URL=... PIPELINES_TOKEN=... PIPELINES_TENANT=... PIPELINES_NAMESPACE=... pnpm vitest run src/conformance/api.test.ts
307
+ ```
308
+
242
309
  ## Dependencies
243
310
 
244
311
  | Package | Why |
package/dist/client.d.ts CHANGED
@@ -3,6 +3,7 @@ import type { Client, Transport } from "@connectrpc/connect";
3
3
  import type { RunState } from "./gen/xeonr/pipelines/v1/common_pb.js";
4
4
  import type { Definition } from "./gen/xeonr/pipelines/v1/definition_pb.js";
5
5
  import { DefinitionSchema } from "./gen/xeonr/pipelines/v1/definition_pb.js";
6
+ import type { RetrySchema } from "./gen/xeonr/pipelines/v1/definition_pb.js";
6
7
  import { RunsService } from "./gen/xeonr/pipelines/v1/runs_pb.js";
7
8
  import type { Exclusion, ExclusionSchema, GetRunGraphResponse, Run } from "./gen/xeonr/pipelines/v1/runs_pb.js";
8
9
  import type { Connection } from "./transport.js";
@@ -53,6 +54,16 @@ export interface CreateJobInput {
53
54
  id: string;
54
55
  json?: JsonObject;
55
56
  };
57
+ /**
58
+ * The job's retry policy, as a node's `retry`. Unset is the platform's
59
+ * default: transient classes only, which retries a handler error only when
60
+ * the worker marked it transient (`TransientError`). List
61
+ * `FailureClass.HANDLER_ERROR` in `when` to retry every handler error; a
62
+ * `PermanentError` is still never retried. `max` is at most 10.
63
+ */
64
+ retry?: MessageInitShape<typeof RetrySchema>;
65
+ /** Bounds one attempt from its start. Unset is the platform's default. */
66
+ timeoutMs?: number;
56
67
  }
57
68
  /** A created run, and whether the idempotency key had been seen. */
58
69
  export interface CreatedRun {
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGvE,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,KAAK,EAAkB,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2CAA2C,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,mBAAmB,EAAE,GAAG,EAAE,MAAM,qCAAqC,CAAC;AAEhH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,uEAAuE;AACvE,M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O,WAAW,CAAC,CAAC;IAC1C,0DAA0D;IAC1D,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;gBAEvB,IAAI,EAAE,sBAAsB;IAMxC;;;;OAIG;IACG,SAAS,CAAC,KAAK,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IAgBjF;;;;OAIG;IACG,SAAS,CAAC,KAAK,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IAuBjF,gCAAgC;IAC1B,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC;IAI/D,oGAAoG;IAC9F,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAIpF,wDAAwD;IAClD,QAAQ,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,GAAG,EAAE,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;IAcxG;;;OAGG;IACG,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC;IAInF,OAAO,CAAC,IAAI;CAGb"}
package/dist/client.js CHANGED
@@ -50,6 +50,9 @@ export class PipelinesClient {
50
50
  if (input.delayMs !== undefined && (input.delayMs < 0 || !Number.isFinite(input.delayMs))) {
51
51
  throw new RangeError("createJob: delayMs must be a finite, non-negative number");
52
52
  }
53
+ if (input.timeoutMs !== undefined && (input.timeoutMs <= 0 || !Number.isFinite(input.timeoutMs))) {
54
+ throw new RangeError("createJob: timeoutMs must be a finite, positive number");
55
+ }
53
56
  const res = await this.runs.createJob({
54
57
  tenant: input.tenant,
55
58
  handler: input.handler,
@@ -57,6 +60,8 @@ export class PipelinesClient {
57
60
  ...(input.payload ? { payload: input.payload } : {}),
58
61
  ...(input.delayMs ? { delay: durationFromMs(input.delayMs) } : {}),
59
62
  ...(input.resource ? { resource: resource(input.resource) } : {}),
63
+ ...(input.retry ? { retry: input.retry } : {}),
64
+ ...(input.timeoutMs ? { timeout: durationFromMs(input.timeoutMs) } : {}),
60
65
  }, this.opts(signal));
61
66
  return { run: required(res.run), deduplicated: res.deduplicated };
62
67
  }
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAInD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AA8D7C;;;;;;;;GAQG;AACH,MAAM,OAAO,eAAe;IAC1B,uEAAuE;IAC9D,IAAI,CAA6B;IAC1C,0DAA0D;IACjD,SAAS,CAAY;IACb,SAAS,CAAS;IAEnC,YAAY,IAA4B;QACtC,IAAI,CAAC,SAAS,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QACtD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,MAAM,CAAC;IAC5C,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,SAAS,CAAC,KAAqB,EAAE,MAAoB;QACzD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAA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,UAAU,EAAE,GAAG,CAAC,UAAU,EAAE,CAAC;IACxD,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,SAAS,CAAC,KAAa,EAAE,MAAe,EAAE,MAAoB;QAClE,OAAO,QAAQ,CAAC,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAChH,CAAC;IAEO,IAAI,CAAC,MAAoB;QAC/B,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IACtE,CAAC;CACF;AAED,SAAS,QAAQ,CAAC,CAAkD;IAClE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;AACzE,CAAC;AAED,SAAS,QAAQ,CAAC,GAAoB;IACpC,IAAI,CAAC,GAAG;QAAE,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAClE,OAAO,GAAG,CAAC;AACb,CAAC"}
package/dist/errors.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { HandlerFailureKind } from "./gen/xeonr/pipelines/private/v1/worker_pb.js";
1
2
  /**
2
3
  * How the SDK treats an error from pipelines-api, decided by its Connect
3
4
  * code. The rules are the API's (WorkerService's comments, and what the api
@@ -8,8 +9,9 @@
8
9
  * work on it and report nothing more.
9
10
  * - `final`: `invalid_argument`, `not_found`, `already_exists`,
10
11
  * `unimplemented`, `out_of_range`. Repeating the same request cannot
11
- * succeed; the caller decides what that means for its operation (for
12
- * `out_of_range` on AppendLogs, it is not fatal to the attempt).
12
+ * succeed; the caller decides what that means for its operation. On
13
+ * AppendLogs, `out_of_range` names the seq the server expects and the log
14
+ * shipper resends or renumbers from it; it is never fatal to the attempt.
13
15
  * - `auth`: `unauthenticated`, `permission_denied`. Not transient: the
14
16
  * credential or its scopes are wrong. A worker stops claiming and surfaces
15
17
  * it.
@@ -51,8 +53,9 @@ export declare class AttemptAbortedError extends Error {
51
53
  * - `lost`: the attempt is no longer this worker's (lease lost). Nothing
52
54
  * the handler returns is reported.
53
55
  * - `shutdown`: the worker is stopping and its shutdown timeout passed.
54
- * The attempt is completed as a worker failure, which the platform
55
- * retries by default.
56
+ * The attempt is completed with `TERMINATION_INTERRUPTED`, which the
57
+ * platform retries by default (and, on an `interruptible` node,
58
+ * without spending the retry budget).
56
59
  */
57
60
  readonly cause: "cancelled" | "deadline" | "lost" | "shutdown";
58
61
  readonly name = "AttemptAbortedError";
@@ -65,8 +68,9 @@ export declare class AttemptAbortedError extends Error {
65
68
  * - `lost`: the attempt is no longer this worker's (lease lost). Nothing
66
69
  * the handler returns is reported.
67
70
  * - `shutdown`: the worker is stopping and its shutdown timeout passed.
68
- * The attempt is completed as a worker failure, which the platform
69
- * retries by default.
71
+ * The attempt is completed with `TERMINATION_INTERRUPTED`, which the
72
+ * platform retries by default (and, on an `interruptible` node,
73
+ * without spending the retry budget).
70
74
  */
71
75
  cause: "cancelled" | "deadline" | "lost" | "shutdown", message: string);
72
76
  }
@@ -74,4 +78,36 @@ export declare class AttemptAbortedError extends Error {
74
78
  export declare class WorkerStartError extends Error {
75
79
  readonly name = "WorkerStartError";
76
80
  }
81
+ /** Brands a thrown value with a failure kind, across duplicate copies of this package. */
82
+ declare const FAILURE_KIND: unique symbol;
83
+ /**
84
+ * Throw from a handler when the failure will not pass on a retry: a payload
85
+ * that fails validation, a 4xx from a downstream service. The attempt is
86
+ * completed with `handler_failure_kind = PERMANENT` and is not retried,
87
+ * whatever the node's `Retry.when` lists (a worker can narrow the policy,
88
+ * never widen it). The class stays `FAILURE_CLASS_HANDLER_ERROR`.
89
+ */
90
+ export declare class PermanentError extends Error {
91
+ readonly name: string;
92
+ readonly [FAILURE_KIND]: "permanent";
93
+ }
94
+ /**
95
+ * Throw from a handler when the failure may pass on its own: a downstream
96
+ * timeout, a 503. The attempt is completed with
97
+ * `handler_failure_kind = TRANSIENT`, so the platform's default policy
98
+ * retries it; an explicit `Retry.when` applies as written, and `Retry.max`
99
+ * and backoff bound it as always.
100
+ */
101
+ export declare class TransientError extends Error {
102
+ readonly name: string;
103
+ readonly [FAILURE_KIND]: "transient";
104
+ }
105
+ /**
106
+ * The handler failure kind a thrown value carries: PERMANENT for a
107
+ * {@link PermanentError}, TRANSIENT for a {@link TransientError} (or any
108
+ * error branded by another copy of this package), UNSPECIFIED otherwise. An
109
+ * error wrapped as the `cause` of another counts too.
110
+ */
111
+ export declare function handlerFailureKind(err: unknown): HandlerFailureKind;
112
+ export {};
77
113
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,WAAW,CAAC;AAE5E,0DAA0D;AAC1D,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,SAAS,CAoBjD;AAED;;;;GAIG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAIzC,+DAA+D;IAC/D,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM;IACxB,yEAAyE;IACzE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM;IAN9B,SAAkB,IAAI,wBAAwB;gBAE5C,OAAO,EAA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,mBAAoB,SAAQ,KAAK;IAG1C;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,UAAU,GAAG,MAAM,GAAG,UAAU;IAdhE,SAAkB,IAAI,yBAAyB;;IAE7C;;;;;;;;;;;OAWG;IACM,KAAK,EAAE,WAAW,GAAG,UAAU,GAAG,MAAM,GAAG,UAAU,EAC9D,OAAO,EAAE,MAAM;CAIlB;AAED,kFAAkF;AAClF,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,SAAkB,IAAI,sBAAsB;CAC7C;AAED,0FAA0F;AAC1F,QAAA,MAAM,YAAY,eAA0D,CAAC;AAE7E;;;;;;GAMG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC,SAAkB,IAAI,EAAE,MAAM,CAAoB;IAClD,QAAQ,CAAC,CAAC,YAAY,CAAC,EAAG,WAAW,CAAU;CAChD;AAED;;;;;;GAMG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC,SAAkB,IAAI,EAAE,MAAM,CAAoB;IAClD,QAAQ,CAAC,CAAC,YAAY,CAAC,EAAG,WAAW,CAAU;CAChD;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,GAAG,kBAAkB,CAQnE"}
package/dist/errors.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Code, ConnectError } from "@connectrpc/connect";
2
+ import { HandlerFailureKind } from "./gen/xeonr/pipelines/private/v1/worker_pb.js";
2
3
  /** Classifies an error thrown by a pipelines-api call. */
3
4
  export function errorKind(err) {
4
5
  if (err instanceof PipelinesAuthError)
@@ -57,8 +58,9 @@ export class AttemptAbortedError extends Error {
57
58
  * - `lost`: the attempt is no longer this worker's (lease lost). Nothing
58
59
  * the handler returns is reported.
59
60
  * - `shutdown`: the worker is stopping and its shutdown timeout passed.
60
- * The attempt is completed as a worker failure, which the platform
61
- * retries by default.
61
+ * The attempt is completed with `TERMINATION_INTERRUPTED`, which the
62
+ * platform retries by default (and, on an `interruptible` node,
63
+ * without spending the retry budget).
62
64
  */
63
65
  cause, message) {
64
66
  super(message);
@@ -69,4 +71,45 @@ export class AttemptAbortedError extends Error {
69
71
  export class WorkerStartError extends Error {
70
72
  name = "WorkerStartError";
71
73
  }
74
+ /** Brands a thrown value with a failure kind, across duplicate copies of this package. */
75
+ const FAILURE_KIND = Symbol.for("@xeonr/pipelines-sdk/handler-failure-kind");
76
+ /**
77
+ * Throw from a handler when the failure will not pass on a retry: a payload
78
+ * that fails validation, a 4xx from a downstream service. The attempt is
79
+ * completed with `handler_failure_kind = PERMANENT` and is not retried,
80
+ * whatever the node's `Retry.when` lists (a worker can narrow the policy,
81
+ * never widen it). The class stays `FAILURE_CLASS_HANDLER_ERROR`.
82
+ */
83
+ export class PermanentError extends Error {
84
+ name = "PermanentError";
85
+ [FAILURE_KIND] = "permanent";
86
+ }
87
+ /**
88
+ * Throw from a handler when the failure may pass on its own: a downstream
89
+ * timeout, a 503. The attempt is completed with
90
+ * `handler_failure_kind = TRANSIENT`, so the platform's default policy
91
+ * retries it; an explicit `Retry.when` applies as written, and `Retry.max`
92
+ * and backoff bound it as always.
93
+ */
94
+ export class TransientError extends Error {
95
+ name = "TransientError";
96
+ [FAILURE_KIND] = "transient";
97
+ }
98
+ /**
99
+ * The handler failure kind a thrown value carries: PERMANENT for a
100
+ * {@link PermanentError}, TRANSIENT for a {@link TransientError} (or any
101
+ * error branded by another copy of this package), UNSPECIFIED otherwise. An
102
+ * error wrapped as the `cause` of another counts too.
103
+ */
104
+ export function handlerFailureKind(err) {
105
+ for (let e = err, depth = 0; e !== null && typeof e === "object" && depth < 8; depth++) {
106
+ const kind = e[FAILURE_KIND];
107
+ if (kind === "permanent")
108
+ return HandlerFailureKind.PERMANENT;
109
+ if (kind === "transient")
110
+ return HandlerFailureKind.TRANSIENT;
111
+ e = e.cause;
112
+ }
113
+ return HandlerFailureKind.UNSPECIFIED;
114
+ }
72
115
  //# sourceMappingURL=errors.js.map
@@ -1 +1 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