Skip to content

Commit 76866c8

Browse files
yaron2famarting
andauthored
Update durabletask-js (#633)
* update durabletask-js Signed-off-by: yaron2 <[email protected]> * update sha Signed-off-by: yaron2 <[email protected]> * adapt durabletask clients initialization --------- Signed-off-by: yaron2 <[email protected]> Co-authored-by: Fabian Martinez <[email protected]>
1 parent 4c05477 commit 76866c8

File tree

7 files changed

+31
-19
lines changed

7 files changed

+31
-19
lines changed

examples/workflow/authoring/package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/workflow/management/package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"dependencies": {
4949
"@grpc/grpc-js": "^1.9.3",
5050
"@js-temporal/polyfill": "^0.3.0",
51-
"@microsoft/durabletask-js": "^0.1.0-alpha.1",
51+
"@microsoft/durabletask-js": "^0.1.0-alpha.2",
5252
"@types/google-protobuf": "^3.15.5",
5353
"@types/node-fetch": "^2.6.2",
5454
"body-parser": "^1.19.0",

src/workflow/client/DaprWorkflowClient.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { generateApiTokenClientInterceptors, generateEndpoint, getDaprApiToken }
1717
import { TWorkflow } from "../../types/workflow/Workflow.type";
1818
import { getFunctionName } from "../internal";
1919
import { WorkflowClientOptions } from "../../types/workflow/WorkflowClientOption";
20+
import { GrpcEndpoint } from "../../network/GrpcEndpoint";
2021

2122
/**
2223
* Class that defines client operations for managing workflow instances.
@@ -34,18 +35,18 @@ export default class DaprWorkflowClient {
3435
constructor(options: Partial<WorkflowClientOptions> = {}) {
3536
const grpcEndpoint = generateEndpoint(options);
3637
options.daprApiToken = getDaprApiToken(options);
37-
this._innerClient = this.buildInnerClient(grpcEndpoint.endpoint, options);
38+
this._innerClient = this.buildInnerClient(grpcEndpoint, options);
3839
}
3940

40-
private buildInnerClient(hostAddress: string, options: Partial<WorkflowClientOptions>): TaskHubGrpcClient {
41+
private buildInnerClient(grpcEndpoint: GrpcEndpoint, options: Partial<WorkflowClientOptions>): TaskHubGrpcClient {
4142
let innerOptions = options?.grpcOptions;
4243
if (options.daprApiToken !== undefined && options.daprApiToken !== "") {
4344
innerOptions = {
4445
...innerOptions,
4546
interceptors: [generateApiTokenClientInterceptors(options), ...(innerOptions?.interceptors ?? [])],
4647
};
4748
}
48-
return new TaskHubGrpcClient(hostAddress, innerOptions);
49+
return new TaskHubGrpcClient(grpcEndpoint.endpoint, innerOptions, grpcEndpoint.tls);
4950
}
5051

5152
/**

src/workflow/internal/index.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,19 @@ export function getFunctionName(fn: TWorkflow | TWorkflowActivity<TInput, TOutpu
4848
* @returns A GrpcEndpoint representing the Dapr gRPC endpoint.
4949
*/
5050
export function generateEndpoint(options: Partial<WorkflowClientOptions>): GrpcEndpoint {
51+
// NOTE: same logic as src/implementation/Client/GRPCClient/GRPCClient.ts
5152
const host = options?.daprHost ?? Settings.getDefaultHost();
5253
const port = options?.daprPort ?? Settings.getDefaultGrpcPort();
53-
const uri = `${host}:${port}`;
54+
let uri = `${host}:${port}`;
55+
56+
if (!(options?.daprHost || options?.daprPort)) {
57+
// If neither host nor port are specified, check the endpoint environment variable.
58+
const endpoint = Settings.getDefaultGrpcEndpoint();
59+
if (endpoint != "") {
60+
uri = endpoint;
61+
}
62+
}
63+
5464
return new GrpcEndpoint(uri);
5565
}
5666

src/workflow/runtime/WorkflowRuntime.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import WorkflowContext from "./WorkflowContext";
2020
import { generateApiTokenClientInterceptors, generateEndpoint, getDaprApiToken } from "../internal/index";
2121
import { getFunctionName } from "../internal";
2222
import { WorkflowClientOptions } from "../../types/workflow/WorkflowClientOption";
23+
import { GrpcEndpoint } from "../../network/GrpcEndpoint";
2324

2425
/**
2526
* Contains methods to register workflows and activities.
@@ -34,18 +35,18 @@ export default class WorkflowRuntime {
3435
constructor(options: Partial<WorkflowClientOptions> = {}) {
3536
const grpcEndpoint = generateEndpoint(options);
3637
options.daprApiToken = getDaprApiToken(options);
37-
this.worker = this.buildInnerWorker(grpcEndpoint.endpoint, options);
38+
this.worker = this.buildInnerWorker(grpcEndpoint, options);
3839
}
3940

40-
private buildInnerWorker(hostAddress: string, options: Partial<WorkflowClientOptions>): TaskHubGrpcWorker {
41+
private buildInnerWorker(grpcEndpoint: GrpcEndpoint, options: Partial<WorkflowClientOptions>): TaskHubGrpcWorker {
4142
let innerOptions = options?.grpcOptions;
4243
if (options.daprApiToken !== undefined && options.daprApiToken !== "") {
4344
innerOptions = {
4445
...innerOptions,
4546
interceptors: [generateApiTokenClientInterceptors(options), ...(innerOptions?.interceptors ?? [])],
4647
};
4748
}
48-
return new TaskHubGrpcWorker(hostAddress, innerOptions);
49+
return new TaskHubGrpcWorker(grpcEndpoint.endpoint, innerOptions, grpcEndpoint.tls);
4950
}
5051

5152
/**

0 commit comments

Comments
 (0)