@temporalio/client 1.4.1 → 1.4.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/lib/connection.d.ts +18 -5
- package/lib/connection.js +7 -8
- package/lib/connection.js.map +1 -1
- package/package.json +4 -4
- package/src/connection.ts +24 -10
package/lib/connection.d.ts
CHANGED
|
@@ -33,13 +33,27 @@ export interface ConnectionOptions {
|
|
|
33
33
|
* GRPC Channel arguments
|
|
34
34
|
*
|
|
35
35
|
* @see option descriptions {@link https://grpc.github.io/grpc/core/group__grpc__arg__keys.html | here}
|
|
36
|
+
*
|
|
37
|
+
* By default the SDK sets the following keepalive arguments:
|
|
38
|
+
*
|
|
39
|
+
* ```
|
|
40
|
+
* grpc.keepalive_permit_without_calls: 1
|
|
41
|
+
* grpc.keepalive_time_ms: 30_000
|
|
42
|
+
* grpc.keepalive_timeout_ms: 15_000
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* To opt-out of keepalive, override these keys with `undefined`.
|
|
36
46
|
*/
|
|
37
47
|
channelArgs?: grpc.ChannelOptions;
|
|
38
48
|
/**
|
|
39
|
-
* Grpc interceptors which will be applied to every RPC call performed by this connection. By
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* interceptors
|
|
49
|
+
* Grpc interceptors which will be applied to every RPC call performed by this connection. By default, an interceptor
|
|
50
|
+
* will be included which automatically retries retryable errors. If you do not wish to perform automatic retries, set
|
|
51
|
+
* this to an empty list (or a list with your own interceptors). If you want to add your own interceptors while
|
|
52
|
+
* keeping the default retry behavior, add this to your list of interceptors:
|
|
53
|
+
* `makeGrpcRetryInterceptor(defaultGrpcRetryOptions())`. See:
|
|
54
|
+
*
|
|
55
|
+
* - @link makeGrpcRetryInterceptor
|
|
56
|
+
* - @link defaultGrpcRetryOptions
|
|
43
57
|
*/
|
|
44
58
|
interceptors?: grpc.Interceptor[];
|
|
45
59
|
/**
|
|
@@ -63,7 +77,6 @@ export declare type ConnectionOptionsWithDefaults = Required<Omit<ConnectionOpti
|
|
|
63
77
|
connectTimeoutMs: number;
|
|
64
78
|
};
|
|
65
79
|
export declare const LOCAL_TARGET = "127.0.0.1:7233";
|
|
66
|
-
export declare function defaultConnectionOpts(): ConnectionOptionsWithDefaults;
|
|
67
80
|
export interface RPCImplOptions {
|
|
68
81
|
serviceName: string;
|
|
69
82
|
client: grpc.Client;
|
package/lib/connection.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.Connection = exports.
|
|
29
|
+
exports.Connection = exports.LOCAL_TARGET = void 0;
|
|
30
30
|
const grpc = __importStar(require("@grpc/grpc-js"));
|
|
31
31
|
const internal_non_workflow_1 = require("@temporalio/common/lib/internal-non-workflow");
|
|
32
32
|
const async_hooks_1 = require("async_hooks");
|
|
@@ -35,7 +35,8 @@ const grpc_retry_1 = require("./grpc-retry");
|
|
|
35
35
|
const pkg_1 = __importDefault(require("./pkg"));
|
|
36
36
|
const types_1 = require("./types");
|
|
37
37
|
exports.LOCAL_TARGET = '127.0.0.1:7233';
|
|
38
|
-
function
|
|
38
|
+
function addDefaults(options) {
|
|
39
|
+
const { channelArgs, interceptors, ...rest } = options;
|
|
39
40
|
return {
|
|
40
41
|
address: exports.LOCAL_TARGET,
|
|
41
42
|
credentials: grpc.credentials.createInsecure(),
|
|
@@ -43,13 +44,14 @@ function defaultConnectionOpts() {
|
|
|
43
44
|
'grpc.keepalive_permit_without_calls': 1,
|
|
44
45
|
'grpc.keepalive_time_ms': 30000,
|
|
45
46
|
'grpc.keepalive_timeout_ms': 15000,
|
|
47
|
+
...channelArgs,
|
|
46
48
|
},
|
|
47
|
-
interceptors: [(0, grpc_retry_1.makeGrpcRetryInterceptor)((0, grpc_retry_1.defaultGrpcRetryOptions)())],
|
|
49
|
+
interceptors: interceptors ?? [(0, grpc_retry_1.makeGrpcRetryInterceptor)((0, grpc_retry_1.defaultGrpcRetryOptions)())],
|
|
48
50
|
metadata: {},
|
|
49
51
|
connectTimeoutMs: 10000,
|
|
52
|
+
...(0, internal_non_workflow_1.filterNullAndUndefined)(rest),
|
|
50
53
|
};
|
|
51
54
|
}
|
|
52
|
-
exports.defaultConnectionOpts = defaultConnectionOpts;
|
|
53
55
|
/**
|
|
54
56
|
* - Convert {@link ConnectionOptions.tls} to {@link grpc.ChannelCredentials}
|
|
55
57
|
* - Add the grpc.ssl_target_name_override GRPC {@link ConnectionOptions.channelArgs | channel arg}
|
|
@@ -103,10 +105,7 @@ class Connection {
|
|
|
103
105
|
}
|
|
104
106
|
static createCtorOptions(options) {
|
|
105
107
|
var _a, _b;
|
|
106
|
-
const optionsWithDefaults =
|
|
107
|
-
...defaultConnectionOpts(),
|
|
108
|
-
...(0, internal_non_workflow_1.filterNullAndUndefined)(normalizeGRPCConfig(options)),
|
|
109
|
-
};
|
|
108
|
+
const optionsWithDefaults = addDefaults(normalizeGRPCConfig(options));
|
|
110
109
|
// Allow overriding this
|
|
111
110
|
(_a = optionsWithDefaults.metadata)['client-name'] ?? (_a['client-name'] = 'temporal-typescript');
|
|
112
111
|
(_b = optionsWithDefaults.metadata)['client-version'] ?? (_b['client-version'] = pkg_1.default.version);
|
package/lib/connection.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AACtC,wFAAqH;AACrH,6CAAgD;AAEhD,qCAA+D;AAC/D,6CAAiF;AACjF,gDAAwB;AACxB,mCAAiG;
|
|
1
|
+
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AAC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AAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;IACrF,CAAC;IAED;;;;OAIG;IACO,KAAK,CAAC,UAAU,CAAC,QAAgB;QACzC,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC3C,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE;gBACzC,IAAI,GAAG,EAAE;oBACP,MAAM,CAAC,GAAG,CAAC,CAAC;iBACb;qBAAM;oBACL,OAAO,EAAE,CAAC;iBACX;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAED,+GAA+G;IAC/G;;;;OAIG;IACI,KAAK,CAAC,KAAK;QAChB,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;;AAlOH,gCAmOC;AAlOC;;GAEG;AACoB,iBAAM,GAAG,IAAI,CAAC,4BAA4B,CAAC,EAAE,EAAE,iBAAiB,EAAE,EAAE,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporalio/client",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.3",
|
|
4
4
|
"description": "Temporal.io SDK Client sub-package",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@grpc/grpc-js": "^1.6.7",
|
|
17
|
-
"@temporalio/common": "
|
|
18
|
-
"@temporalio/proto": "
|
|
17
|
+
"@temporalio/common": "~1.4.3",
|
|
18
|
+
"@temporalio/proto": "~1.4.3",
|
|
19
19
|
"ms": "^2.1.3",
|
|
20
20
|
"uuid": "^8.3.2"
|
|
21
21
|
},
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"src",
|
|
34
34
|
"lib"
|
|
35
35
|
],
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "be51cfac7016b66151d70dbd5aca7f7ef02b260a"
|
|
37
37
|
}
|
package/src/connection.ts
CHANGED
|
@@ -39,14 +39,28 @@ export interface ConnectionOptions {
|
|
|
39
39
|
* GRPC Channel arguments
|
|
40
40
|
*
|
|
41
41
|
* @see option descriptions {@link https://grpc.github.io/grpc/core/group__grpc__arg__keys.html | here}
|
|
42
|
+
*
|
|
43
|
+
* By default the SDK sets the following keepalive arguments:
|
|
44
|
+
*
|
|
45
|
+
* ```
|
|
46
|
+
* grpc.keepalive_permit_without_calls: 1
|
|
47
|
+
* grpc.keepalive_time_ms: 30_000
|
|
48
|
+
* grpc.keepalive_timeout_ms: 15_000
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* To opt-out of keepalive, override these keys with `undefined`.
|
|
42
52
|
*/
|
|
43
53
|
channelArgs?: grpc.ChannelOptions;
|
|
44
54
|
|
|
45
55
|
/**
|
|
46
|
-
* Grpc interceptors which will be applied to every RPC call performed by this connection. By
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* interceptors
|
|
56
|
+
* Grpc interceptors which will be applied to every RPC call performed by this connection. By default, an interceptor
|
|
57
|
+
* will be included which automatically retries retryable errors. If you do not wish to perform automatic retries, set
|
|
58
|
+
* this to an empty list (or a list with your own interceptors). If you want to add your own interceptors while
|
|
59
|
+
* keeping the default retry behavior, add this to your list of interceptors:
|
|
60
|
+
* `makeGrpcRetryInterceptor(defaultGrpcRetryOptions())`. See:
|
|
61
|
+
*
|
|
62
|
+
* - @link makeGrpcRetryInterceptor
|
|
63
|
+
* - @link defaultGrpcRetryOptions
|
|
50
64
|
*/
|
|
51
65
|
interceptors?: grpc.Interceptor[];
|
|
52
66
|
|
|
@@ -75,7 +89,8 @@ export type ConnectionOptionsWithDefaults = Required<Omit<ConnectionOptions, 'tl
|
|
|
75
89
|
|
|
76
90
|
export const LOCAL_TARGET = '127.0.0.1:7233';
|
|
77
91
|
|
|
78
|
-
|
|
92
|
+
function addDefaults(options: ConnectionOptions): ConnectionOptionsWithDefaults {
|
|
93
|
+
const { channelArgs, interceptors, ...rest } = options;
|
|
79
94
|
return {
|
|
80
95
|
address: LOCAL_TARGET,
|
|
81
96
|
credentials: grpc.credentials.createInsecure(),
|
|
@@ -83,10 +98,12 @@ export function defaultConnectionOpts(): ConnectionOptionsWithDefaults {
|
|
|
83
98
|
'grpc.keepalive_permit_without_calls': 1,
|
|
84
99
|
'grpc.keepalive_time_ms': 30_000,
|
|
85
100
|
'grpc.keepalive_timeout_ms': 15_000,
|
|
101
|
+
...channelArgs,
|
|
86
102
|
},
|
|
87
|
-
interceptors: [makeGrpcRetryInterceptor(defaultGrpcRetryOptions())],
|
|
103
|
+
interceptors: interceptors ?? [makeGrpcRetryInterceptor(defaultGrpcRetryOptions())],
|
|
88
104
|
metadata: {},
|
|
89
105
|
connectTimeoutMs: 10_000,
|
|
106
|
+
...filterNullAndUndefined(rest),
|
|
90
107
|
};
|
|
91
108
|
}
|
|
92
109
|
|
|
@@ -192,10 +209,7 @@ export class Connection {
|
|
|
192
209
|
readonly callContextStorage: AsyncLocalStorage<CallContext>;
|
|
193
210
|
|
|
194
211
|
protected static createCtorOptions(options?: ConnectionOptions): ConnectionCtorOptions {
|
|
195
|
-
const optionsWithDefaults =
|
|
196
|
-
...defaultConnectionOpts(),
|
|
197
|
-
...filterNullAndUndefined(normalizeGRPCConfig(options)),
|
|
198
|
-
};
|
|
212
|
+
const optionsWithDefaults = addDefaults(normalizeGRPCConfig(options));
|
|
199
213
|
// Allow overriding this
|
|
200
214
|
optionsWithDefaults.metadata['client-name'] ??= 'temporal-typescript';
|
|
201
215
|
optionsWithDefaults.metadata['client-version'] ??= pkg.version;
|