@temporalio/client 1.11.6 → 1.11.8
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 +3 -2
- package/lib/connection.js +21 -1
- package/lib/connection.js.map +1 -1
- package/package.json +4 -4
- package/src/connection.ts +34 -4
package/lib/connection.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
2
|
import * as grpc from '@grpc/grpc-js';
|
|
3
|
-
import type
|
|
3
|
+
import type * as proto from 'protobufjs';
|
|
4
4
|
import { TLSConfig } from '@temporalio/common/lib/internal-non-workflow';
|
|
5
5
|
import { Duration } from '@temporalio/common/lib/time';
|
|
6
6
|
import { CallContext, HealthService, Metadata, OperatorService, WorkflowService } from './types';
|
|
@@ -208,7 +208,7 @@ export declare class Connection {
|
|
|
208
208
|
*/
|
|
209
209
|
static connect(options?: ConnectionOptions): Promise<Connection>;
|
|
210
210
|
protected constructor({ options, client, workflowService, operatorService, healthService, callContextStorage, apiKeyFnRef, }: ConnectionCtorOptions);
|
|
211
|
-
protected static generateRPCImplementation({ serviceName, client, callContextStorage, interceptors, staticMetadata, apiKeyFnRef, }: RPCImplOptions): RPCImpl;
|
|
211
|
+
protected static generateRPCImplementation({ serviceName, client, callContextStorage, interceptors, staticMetadata, apiKeyFnRef, }: RPCImplOptions): proto.RPCImpl;
|
|
212
212
|
/**
|
|
213
213
|
* Set a deadline for any service requests executed in `fn`'s scope.
|
|
214
214
|
*
|
|
@@ -295,4 +295,5 @@ export declare class Connection {
|
|
|
295
295
|
* Make sure to call this method to ensure proper resource cleanup.
|
|
296
296
|
*/
|
|
297
297
|
close(): Promise<void>;
|
|
298
|
+
private withNamespaceHeaderInjector;
|
|
298
299
|
}
|
package/lib/connection.js
CHANGED
|
@@ -219,7 +219,7 @@ class Connection {
|
|
|
219
219
|
constructor({ options, client, workflowService, operatorService, healthService, callContextStorage, apiKeyFnRef, }) {
|
|
220
220
|
this.options = options;
|
|
221
221
|
this.client = client;
|
|
222
|
-
this.workflowService = workflowService;
|
|
222
|
+
this.workflowService = this.withNamespaceHeaderInjector(workflowService);
|
|
223
223
|
this.operatorService = operatorService;
|
|
224
224
|
this.healthService = healthService;
|
|
225
225
|
this.callContextStorage = callContextStorage;
|
|
@@ -289,6 +289,8 @@ class Connection {
|
|
|
289
289
|
*
|
|
290
290
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal
|
|
291
291
|
*/
|
|
292
|
+
// FIXME: `abortSignal` should be cumulative, i.e. if a signal is already set, it should be added
|
|
293
|
+
// to the list of signals, and both the new and existing signal should abort the request.
|
|
292
294
|
async withAbortSignal(abortSignal, fn) {
|
|
293
295
|
const cc = this.callContextStorage.getStore();
|
|
294
296
|
return await this.callContextStorage.run({ ...cc, abortSignal }, fn);
|
|
@@ -378,6 +380,24 @@ class Connection {
|
|
|
378
380
|
this.client.close();
|
|
379
381
|
this.callContextStorage.disable();
|
|
380
382
|
}
|
|
383
|
+
withNamespaceHeaderInjector(workflowService) {
|
|
384
|
+
const wrapper = {};
|
|
385
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
386
|
+
for (const [methodName, methodImpl] of Object.entries(workflowService)) {
|
|
387
|
+
if (typeof methodImpl !== 'function')
|
|
388
|
+
continue;
|
|
389
|
+
wrapper[methodName] = (...args) => {
|
|
390
|
+
const namespace = args[0]?.namespace;
|
|
391
|
+
if (namespace) {
|
|
392
|
+
return this.withMetadata({ 'temporal-namespace': namespace }, () => methodImpl.apply(workflowService, args));
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
return methodImpl.apply(workflowService, args);
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
return wrapper;
|
|
400
|
+
}
|
|
381
401
|
}
|
|
382
402
|
exports.Connection = Connection;
|
|
383
403
|
/**
|
package/lib/connection.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAAqD;AACrD,oDAAsC;AAEtC,wFAKsD;AACtD,sDAA2E;
|
|
1
|
+
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAAqD;AACrD,oDAAsC;AAEtC,wFAKsD;AACtD,sDAA2E;AAE3E,qCAA4D;AAC5D,6CAAiF;AACjF,gDAAwB;AACxB,mCAAiG;AAEjG;;GAEG;AACH,MAAM,0BAA0B,GAAG,IAAI,CAAC;AAyH3B,QAAA,YAAY,GAAG,gBAAgB,CAAC;AAE7C,SAAS,WAAW,CAAC,OAA0B;IAC7C,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IACvE,OAAO;QACL,OAAO,EAAE,oBAAY;QACrB,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,cAAc,EAAE;QAC9C,WAAW,EAAE;YACX,qCAAqC,EAAE,CAAC;YACxC,wBAAwB,EAAE,MAAM;YAChC,2BAA2B,EAAE,MAAM;YACnC,0BAA0B,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI,EAAE,SAAS;YACxD,GAAG,WAAW;SACf;QACD,YAAY,EAAE,YAAY,IAAI,CAAC,IAAA,qCAAwB,EAAC,IAAA,oCAAuB,GAAE,CAAC,CAAC;QACnF,QAAQ,EAAE,EAAE;QACZ,gBAAgB,EAAE,IAAA,yBAAkB,EAAC,cAAc,CAAC,IAAI,MAAM;QAC9D,GAAG,IAAA,8CAAsB,EAAC,IAAI,CAAC;KAChC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAS,mBAAmB,CAAC,OAA2B;IACtD,MAAM,EAAE,GAAG,EAAE,aAAa,EAAE,WAAW,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B,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACpB,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,CAAC;IACpC,CAAC;IAEO,2BAA2B,CACjC,eAAgE;QAEhE,MAAM,OAAO,GAAQ,EAAE,CAAC;QAExB,sEAAsE;QACtE,KAAK,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,eAAe,CAAyB,EAAE,CAAC;YAC/F,IAAI,OAAO,UAAU,KAAK,UAAU;gBAAE,SAAS;YAE/C,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,IAAW,EAAE,EAAE;gBACvC,MAAM,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC;gBACrC,IAAI,SAAS,EAAE,CAAC;oBACd,OAAO,IAAI,CAAC,YAAY,CAAC,EAAE,oBAAoB,EAAE,SAAS,EAAE,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC,CAAC;gBAC/G,CAAC;qBAAM,CAAC;oBACN,OAAO,UAAU,CAAC,KAAK,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;gBACjD,CAAC;YACH,CAAC,CAAC;QACJ,CAAC;QACD,OAAO,OAA0B,CAAC;IACpC,CAAC;;AA5XH,gCA6XC;AA5XC;;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.11.
|
|
3
|
+
"version": "1.11.8",
|
|
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.10.7",
|
|
17
|
-
"@temporalio/common": "1.11.
|
|
18
|
-
"@temporalio/proto": "1.11.
|
|
17
|
+
"@temporalio/common": "1.11.8",
|
|
18
|
+
"@temporalio/proto": "1.11.8",
|
|
19
19
|
"abort-controller": "^3.0.0",
|
|
20
20
|
"long": "^5.2.3",
|
|
21
21
|
"uuid": "^9.0.1"
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"src",
|
|
40
40
|
"lib"
|
|
41
41
|
],
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "0a757c370012d89babb668fbd799d83b55c83a1b"
|
|
43
43
|
}
|
package/src/connection.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
2
|
import * as grpc from '@grpc/grpc-js';
|
|
3
|
-
import type
|
|
3
|
+
import type * as proto from 'protobufjs';
|
|
4
4
|
import {
|
|
5
5
|
filterNullAndUndefined,
|
|
6
6
|
normalizeTlsConfig,
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
normalizeGrpcEndpointAddress,
|
|
9
9
|
} from '@temporalio/common/lib/internal-non-workflow';
|
|
10
10
|
import { Duration, msOptionalToNumber } from '@temporalio/common/lib/time';
|
|
11
|
+
import { type temporal } from '@temporalio/proto';
|
|
11
12
|
import { isGrpcServiceError, ServiceError } from './errors';
|
|
12
13
|
import { defaultGrpcRetryOptions, makeGrpcRetryInterceptor } from './grpc-retry';
|
|
13
14
|
import pkg from './pkg';
|
|
@@ -419,7 +420,7 @@ export class Connection {
|
|
|
419
420
|
}: ConnectionCtorOptions) {
|
|
420
421
|
this.options = options;
|
|
421
422
|
this.client = client;
|
|
422
|
-
this.workflowService = workflowService;
|
|
423
|
+
this.workflowService = this.withNamespaceHeaderInjector(workflowService);
|
|
423
424
|
this.operatorService = operatorService;
|
|
424
425
|
this.healthService = healthService;
|
|
425
426
|
this.callContextStorage = callContextStorage;
|
|
@@ -433,8 +434,12 @@ export class Connection {
|
|
|
433
434
|
interceptors,
|
|
434
435
|
staticMetadata,
|
|
435
436
|
apiKeyFnRef,
|
|
436
|
-
}: RPCImplOptions): RPCImpl {
|
|
437
|
-
return (
|
|
437
|
+
}: RPCImplOptions): proto.RPCImpl {
|
|
438
|
+
return (
|
|
439
|
+
method: proto.Method | proto.rpc.ServiceMethod<proto.Message<any>, proto.Message<any>>,
|
|
440
|
+
requestData: Uint8Array,
|
|
441
|
+
callback: grpc.requestCallback<any>
|
|
442
|
+
) => {
|
|
438
443
|
const metadataContainer = new grpc.Metadata();
|
|
439
444
|
const { metadata, deadline, abortSignal } = callContextStorage.getStore() ?? {};
|
|
440
445
|
if (apiKeyFnRef.fn) {
|
|
@@ -449,6 +454,7 @@ export class Connection {
|
|
|
449
454
|
metadataContainer.set(k, v);
|
|
450
455
|
}
|
|
451
456
|
}
|
|
457
|
+
|
|
452
458
|
const call = client.makeUnaryRequest(
|
|
453
459
|
`/${serviceName}/${method.name}`,
|
|
454
460
|
(arg: any) => arg,
|
|
@@ -458,6 +464,7 @@ export class Connection {
|
|
|
458
464
|
{ interceptors, deadline },
|
|
459
465
|
callback
|
|
460
466
|
);
|
|
467
|
+
|
|
461
468
|
if (abortSignal != null) {
|
|
462
469
|
abortSignal.addEventListener('abort', () => call.cancel());
|
|
463
470
|
}
|
|
@@ -507,6 +514,8 @@ export class Connection {
|
|
|
507
514
|
*
|
|
508
515
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal
|
|
509
516
|
*/
|
|
517
|
+
// FIXME: `abortSignal` should be cumulative, i.e. if a signal is already set, it should be added
|
|
518
|
+
// to the list of signals, and both the new and existing signal should abort the request.
|
|
510
519
|
async withAbortSignal<ReturnType>(abortSignal: AbortSignal, fn: () => Promise<ReturnType>): Promise<ReturnType> {
|
|
511
520
|
const cc = this.callContextStorage.getStore();
|
|
512
521
|
return await this.callContextStorage.run({ ...cc, abortSignal }, fn);
|
|
@@ -605,4 +614,25 @@ export class Connection {
|
|
|
605
614
|
this.client.close();
|
|
606
615
|
this.callContextStorage.disable();
|
|
607
616
|
}
|
|
617
|
+
|
|
618
|
+
private withNamespaceHeaderInjector(
|
|
619
|
+
workflowService: temporal.api.workflowservice.v1.WorkflowService
|
|
620
|
+
): temporal.api.workflowservice.v1.WorkflowService {
|
|
621
|
+
const wrapper: any = {};
|
|
622
|
+
|
|
623
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
624
|
+
for (const [methodName, methodImpl] of Object.entries(workflowService) as [string, Function][]) {
|
|
625
|
+
if (typeof methodImpl !== 'function') continue;
|
|
626
|
+
|
|
627
|
+
wrapper[methodName] = (...args: any[]) => {
|
|
628
|
+
const namespace = args[0]?.namespace;
|
|
629
|
+
if (namespace) {
|
|
630
|
+
return this.withMetadata({ 'temporal-namespace': namespace }, () => methodImpl.apply(workflowService, args));
|
|
631
|
+
} else {
|
|
632
|
+
return methodImpl.apply(workflowService, args);
|
|
633
|
+
}
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
return wrapper as WorkflowService;
|
|
637
|
+
}
|
|
608
638
|
}
|