@databricks/sdk-jobs 0.1.0-dev.1 → 0.1.0-dev.3

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/src/v2/utils.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
2
 
3
- import type {Call, Options} from '@databricks/sdk-core/api';
4
- import {execute} from '@databricks/sdk-core/api';
3
+ import type {Options} from '@databricks/sdk-core/ops';
4
+ import {execute, retryOn} from '@databricks/sdk-core/ops';
5
5
  import {ApiError} from '@databricks/sdk-core/apierror';
6
6
  import type {
7
7
  HttpClient,
@@ -10,6 +10,7 @@ import type {
10
10
  } from '@databricks/sdk-core/http';
11
11
  import type {Logger} from '@databricks/sdk-core/logger';
12
12
  import type {CallOptions} from '@databricks/sdk-options/call';
13
+ import type {LroOptions} from '@databricks/sdk-options/lro';
13
14
  import JSONBig from 'json-bigint';
14
15
  import type {z} from 'zod';
15
16
 
@@ -30,7 +31,7 @@ export interface HttpCallOptions {
30
31
  * API from the executor's internal type so they can diverge.
31
32
  */
32
33
  export async function executeCall(
33
- call: Call,
34
+ call: (signal?: AbortSignal) => Promise<void>,
34
35
  options?: CallOptions
35
36
  ): Promise<void> {
36
37
  const opts: Options = {
@@ -43,6 +44,29 @@ export async function executeCall(
43
44
  return execute(options?.signal, call, opts);
44
45
  }
45
46
 
47
+ /**
48
+ * Sentinel thrown by a polling call to signal that the operation has not
49
+ * yet reached a terminal state. {@link executeWait} treats this error as
50
+ * retriable; any other error aborts the wait.
51
+ */
52
+ export class StillRunningError extends Error {}
53
+
54
+ /**
55
+ * Polls until the call returns without throwing {@link StillRunningError}.
56
+ * Abort and overall-deadline behavior come from the supplied LroOptions.
57
+ */
58
+ export async function executeWait(
59
+ call: (signal?: AbortSignal) => Promise<void>,
60
+ options?: LroOptions
61
+ ): Promise<void> {
62
+ const opts: Options = {
63
+ ...(options?.timeout !== undefined && {timeout: options.timeout}),
64
+ retrier: () =>
65
+ retryOn({}, (err: Error) => err instanceof StillRunningError),
66
+ };
67
+ return execute(options?.signal, call, opts);
68
+ }
69
+
46
70
  async function readAll(
47
71
  body: ReadableStream<Uint8Array> | null
48
72
  ): Promise<Uint8Array> {