From 76866c878a6e79bb889c83f3930172ddb20f1624 Mon Sep 17 00:00:00 2001 From: Yaron Schneider Date: Thu, 19 Sep 2024 06:21:34 -0700 Subject: [PATCH] Update durabletask-js (#633) * update durabletask-js Signed-off-by: yaron2 * update sha Signed-off-by: yaron2 * adapt durabletask clients initialization --------- Signed-off-by: yaron2 Co-authored-by: Fabian Martinez <46371672+famarting@users.noreply.github.com> --- examples/workflow/authoring/package-lock.json | 4 ++-- examples/workflow/management/package-lock.json | 4 ++-- package-lock.json | 14 +++++++------- package.json | 2 +- src/workflow/client/DaprWorkflowClient.ts | 7 ++++--- src/workflow/internal/index.ts | 12 +++++++++++- src/workflow/runtime/WorkflowRuntime.ts | 7 ++++--- 7 files changed, 31 insertions(+), 19 deletions(-) diff --git a/examples/workflow/authoring/package-lock.json b/examples/workflow/authoring/package-lock.json index ebac4724..ced6d63c 100644 --- a/examples/workflow/authoring/package-lock.json +++ b/examples/workflow/authoring/package-lock.json @@ -25,7 +25,7 @@ "dependencies": { "@grpc/grpc-js": "^1.9.3", "@js-temporal/polyfill": "^0.3.0", - "@microsoft/durabletask-js": "^0.1.0-alpha.1", + "@microsoft/durabletask-js": "^0.1.0-alpha.2", "@types/google-protobuf": "^3.15.5", "@types/node-fetch": "^2.6.2", "body-parser": "^1.19.0", @@ -310,7 +310,7 @@ "requires": { "@grpc/grpc-js": "^1.9.3", "@js-temporal/polyfill": "^0.3.0", - "@microsoft/durabletask-js": "^0.1.0-alpha.1", + "@microsoft/durabletask-js": "^0.1.0-alpha.2", "@types/body-parser": "^1.19.1", "@types/express": "^4.17.15", "@types/google-protobuf": "^3.15.5", diff --git a/examples/workflow/management/package-lock.json b/examples/workflow/management/package-lock.json index c2a8b93c..1c981ceb 100644 --- a/examples/workflow/management/package-lock.json +++ b/examples/workflow/management/package-lock.json @@ -24,7 +24,7 @@ "dependencies": { "@grpc/grpc-js": "^1.9.3", "@js-temporal/polyfill": "^0.3.0", - "@microsoft/durabletask-js": "^0.1.0-alpha.1", + "@microsoft/durabletask-js": "^0.1.0-alpha.2", "@types/google-protobuf": "^3.15.5", "@types/node-fetch": "^2.6.2", "body-parser": "^1.19.0", @@ -302,7 +302,7 @@ "requires": { "@grpc/grpc-js": "^1.9.3", "@js-temporal/polyfill": "^0.3.0", - "@microsoft/durabletask-js": "^0.1.0-alpha.1", + "@microsoft/durabletask-js": "^0.1.0-alpha.2", "@swc/core": "^1.3.55", "@types/body-parser": "^1.19.1", "@types/express": "^4.17.15", diff --git a/package-lock.json b/package-lock.json index d84d3731..03732590 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@grpc/grpc-js": "^1.9.3", "@js-temporal/polyfill": "^0.3.0", - "@microsoft/durabletask-js": "^0.1.0-alpha.1", + "@microsoft/durabletask-js": "^0.1.0-alpha.2", "@types/google-protobuf": "^3.15.5", "@types/node-fetch": "^2.6.2", "body-parser": "^1.19.0", @@ -1262,9 +1262,9 @@ } }, "node_modules/@microsoft/durabletask-js": { - "version": "0.1.0-alpha.1", - "resolved": "https://registry.npmjs.org/@microsoft/durabletask-js/-/durabletask-js-0.1.0-alpha.1.tgz", - "integrity": "sha512-wdBCz86FCj2lknLqyjU+J0Auetxxr7vj0SUjPjnjxRaE0VrM4G3WmX65XDlsligoIg2JEe0M89REzaA6IVh4pw==", + "version": "0.1.0-alpha.2", + "resolved": "https://registry.npmjs.org/@microsoft/durabletask-js/-/durabletask-js-0.1.0-alpha.2.tgz", + "integrity": "sha512-EiUgOyT05JQ9/M/InjTKdXs5Y1XxdXRczb6nizceJglXr8S/myxMnQHDV1QRASxroFCoTyKiDHU6uAq4Cpe/LQ==", "dependencies": { "@grpc/grpc-js": "^1.8.14", "google-protobuf": "^3.21.2" @@ -8455,9 +8455,9 @@ } }, "@microsoft/durabletask-js": { - "version": "0.1.0-alpha.1", - "resolved": "https://registry.npmjs.org/@microsoft/durabletask-js/-/durabletask-js-0.1.0-alpha.1.tgz", - "integrity": "sha512-wdBCz86FCj2lknLqyjU+J0Auetxxr7vj0SUjPjnjxRaE0VrM4G3WmX65XDlsligoIg2JEe0M89REzaA6IVh4pw==", + "version": "0.1.0-alpha.2", + "resolved": "https://registry.npmjs.org/@microsoft/durabletask-js/-/durabletask-js-0.1.0-alpha.2.tgz", + "integrity": "sha512-EiUgOyT05JQ9/M/InjTKdXs5Y1XxdXRczb6nizceJglXr8S/myxMnQHDV1QRASxroFCoTyKiDHU6uAq4Cpe/LQ==", "requires": { "@grpc/grpc-js": "^1.8.14", "google-protobuf": "^3.21.2" diff --git a/package.json b/package.json index c08de91b..d5d5f8f1 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "dependencies": { "@grpc/grpc-js": "^1.9.3", "@js-temporal/polyfill": "^0.3.0", - "@microsoft/durabletask-js": "^0.1.0-alpha.1", + "@microsoft/durabletask-js": "^0.1.0-alpha.2", "@types/google-protobuf": "^3.15.5", "@types/node-fetch": "^2.6.2", "body-parser": "^1.19.0", diff --git a/src/workflow/client/DaprWorkflowClient.ts b/src/workflow/client/DaprWorkflowClient.ts index 8b761610..7bf880e8 100644 --- a/src/workflow/client/DaprWorkflowClient.ts +++ b/src/workflow/client/DaprWorkflowClient.ts @@ -17,6 +17,7 @@ import { generateApiTokenClientInterceptors, generateEndpoint, getDaprApiToken } import { TWorkflow } from "../../types/workflow/Workflow.type"; import { getFunctionName } from "../internal"; import { WorkflowClientOptions } from "../../types/workflow/WorkflowClientOption"; +import { GrpcEndpoint } from "../../network/GrpcEndpoint"; /** * Class that defines client operations for managing workflow instances. @@ -34,10 +35,10 @@ export default class DaprWorkflowClient { constructor(options: Partial = {}) { const grpcEndpoint = generateEndpoint(options); options.daprApiToken = getDaprApiToken(options); - this._innerClient = this.buildInnerClient(grpcEndpoint.endpoint, options); + this._innerClient = this.buildInnerClient(grpcEndpoint, options); } - private buildInnerClient(hostAddress: string, options: Partial): TaskHubGrpcClient { + private buildInnerClient(grpcEndpoint: GrpcEndpoint, options: Partial): TaskHubGrpcClient { let innerOptions = options?.grpcOptions; if (options.daprApiToken !== undefined && options.daprApiToken !== "") { innerOptions = { @@ -45,7 +46,7 @@ export default class DaprWorkflowClient { interceptors: [generateApiTokenClientInterceptors(options), ...(innerOptions?.interceptors ?? [])], }; } - return new TaskHubGrpcClient(hostAddress, innerOptions); + return new TaskHubGrpcClient(grpcEndpoint.endpoint, innerOptions, grpcEndpoint.tls); } /** diff --git a/src/workflow/internal/index.ts b/src/workflow/internal/index.ts index a7549e54..b8869825 100644 --- a/src/workflow/internal/index.ts +++ b/src/workflow/internal/index.ts @@ -48,9 +48,19 @@ export function getFunctionName(fn: TWorkflow | TWorkflowActivity): GrpcEndpoint { + // NOTE: same logic as src/implementation/Client/GRPCClient/GRPCClient.ts const host = options?.daprHost ?? Settings.getDefaultHost(); const port = options?.daprPort ?? Settings.getDefaultGrpcPort(); - const uri = `${host}:${port}`; + let uri = `${host}:${port}`; + + if (!(options?.daprHost || options?.daprPort)) { + // If neither host nor port are specified, check the endpoint environment variable. + const endpoint = Settings.getDefaultGrpcEndpoint(); + if (endpoint != "") { + uri = endpoint; + } + } + return new GrpcEndpoint(uri); } diff --git a/src/workflow/runtime/WorkflowRuntime.ts b/src/workflow/runtime/WorkflowRuntime.ts index bafcbd30..83c6aa9a 100644 --- a/src/workflow/runtime/WorkflowRuntime.ts +++ b/src/workflow/runtime/WorkflowRuntime.ts @@ -20,6 +20,7 @@ import WorkflowContext from "./WorkflowContext"; import { generateApiTokenClientInterceptors, generateEndpoint, getDaprApiToken } from "../internal/index"; import { getFunctionName } from "../internal"; import { WorkflowClientOptions } from "../../types/workflow/WorkflowClientOption"; +import { GrpcEndpoint } from "../../network/GrpcEndpoint"; /** * Contains methods to register workflows and activities. @@ -34,10 +35,10 @@ export default class WorkflowRuntime { constructor(options: Partial = {}) { const grpcEndpoint = generateEndpoint(options); options.daprApiToken = getDaprApiToken(options); - this.worker = this.buildInnerWorker(grpcEndpoint.endpoint, options); + this.worker = this.buildInnerWorker(grpcEndpoint, options); } - private buildInnerWorker(hostAddress: string, options: Partial): TaskHubGrpcWorker { + private buildInnerWorker(grpcEndpoint: GrpcEndpoint, options: Partial): TaskHubGrpcWorker { let innerOptions = options?.grpcOptions; if (options.daprApiToken !== undefined && options.daprApiToken !== "") { innerOptions = { @@ -45,7 +46,7 @@ export default class WorkflowRuntime { interceptors: [generateApiTokenClientInterceptors(options), ...(innerOptions?.interceptors ?? [])], }; } - return new TaskHubGrpcWorker(hostAddress, innerOptions); + return new TaskHubGrpcWorker(grpcEndpoint.endpoint, innerOptions, grpcEndpoint.tls); } /**