diff --git a/examples/workflow/authoring/src/activity-sequence.ts b/examples/workflow/authoring/src/activity-sequence.ts index d1ce5423..227b69e8 100644 --- a/examples/workflow/authoring/src/activity-sequence.ts +++ b/examples/workflow/authoring/src/activity-sequence.ts @@ -11,11 +11,11 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { WorkflowClient, WorkflowActivityContext, WorkflowContext, WorkflowRuntime, TWorkflow } from "@dapr/dapr"; +import { DaprWorkflowClient, WorkflowActivityContext, WorkflowContext, WorkflowRuntime, TWorkflow } from "@dapr/dapr"; (async () => { const grpcEndpoint = "localhost:50001"; - const workflowClient = new WorkflowClient(grpcEndpoint); + const workflowClient = new DaprWorkflowClient(grpcEndpoint); const workflowRuntime = new WorkflowRuntime(grpcEndpoint); const hello = async (_: WorkflowActivityContext, name: string) => { diff --git a/examples/workflow/authoring/src/fanout-fanin.ts b/examples/workflow/authoring/src/fanout-fanin.ts index d53840e3..3fac4091 100644 --- a/examples/workflow/authoring/src/fanout-fanin.ts +++ b/examples/workflow/authoring/src/fanout-fanin.ts @@ -11,13 +11,20 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { Task, WorkflowClient, WorkflowActivityContext, WorkflowContext, WorkflowRuntime, TWorkflow } from "@dapr/dapr"; +import { + Task, + DaprWorkflowClient, + WorkflowActivityContext, + WorkflowContext, + WorkflowRuntime, + TWorkflow, +} from "@dapr/dapr"; // Wrap the entire code in an immediately-invoked async function (async () => { // Update the gRPC client and worker to use a local address and port const grpcServerAddress = "localhost:50001"; - const workflowClient: WorkflowClient = new WorkflowClient(grpcServerAddress); + const workflowClient: DaprWorkflowClient = new DaprWorkflowClient(grpcServerAddress); const workflowRuntime: WorkflowRuntime = new WorkflowRuntime(grpcServerAddress); function getRandomInt(min: number, max: number): number { diff --git a/examples/workflow/authoring/src/human-interaction.ts b/examples/workflow/authoring/src/human-interaction.ts index 700024cd..1211ac38 100644 --- a/examples/workflow/authoring/src/human-interaction.ts +++ b/examples/workflow/authoring/src/human-interaction.ts @@ -11,7 +11,14 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { Task, WorkflowClient, WorkflowActivityContext, WorkflowContext, WorkflowRuntime, TWorkflow } from "@dapr/dapr"; +import { + Task, + DaprWorkflowClient, + WorkflowActivityContext, + WorkflowContext, + WorkflowRuntime, + TWorkflow, +} from "@dapr/dapr"; import * as readlineSync from "readline-sync"; // Wrap the entire code in an immediately-invoked async function @@ -33,7 +40,7 @@ import * as readlineSync from "readline-sync"; // Update the gRPC client and worker to use a local address and port const grpcServerAddress = "localhost:50001"; - const workflowClient: WorkflowClient = new WorkflowClient(grpcServerAddress); + const workflowClient: DaprWorkflowClient = new DaprWorkflowClient(grpcServerAddress); const workflowRuntime: WorkflowRuntime = new WorkflowRuntime(grpcServerAddress); //Activity function that sends an approval request to the manager diff --git a/src/index.ts b/src/index.ts index 770edeed..80b70c83 100644 --- a/src/index.ts +++ b/src/index.ts @@ -40,7 +40,7 @@ import StateConcurrencyEnum from "./enum/StateConcurrency.enum"; import StateConsistencyEnum from "./enum/StateConsistency.enum"; import { StateGetBulkOptions } from "./types/state/StateGetBulkOptions.type"; -import WorkflowClient from "./workflow/client/WorkflowClient"; +import DaprWorkflowClient from "./workflow/client/WorkflowClient"; import WorkflowActivityContext from "./workflow/runtime/WorkflowActivityContext"; import WorkflowContext from "./workflow/runtime/WorkflowContext"; import WorkflowRuntime from "./workflow/runtime/WorkflowRuntime"; @@ -79,7 +79,7 @@ export { StateConsistencyEnum, PubSubBulkPublishResponse, StateGetBulkOptions, - WorkflowClient, + DaprWorkflowClient, WorkflowActivityContext, WorkflowContext, WorkflowRuntime, diff --git a/src/workflow/client/WorkflowClient.ts b/src/workflow/client/WorkflowClient.ts index da485be7..460acebd 100644 --- a/src/workflow/client/WorkflowClient.ts +++ b/src/workflow/client/WorkflowClient.ts @@ -17,8 +17,9 @@ import { WorkflowState } from "./WorkflowState"; import { generateInterceptors } from "../internal/ApiTokenClientInterceptor"; import { TWorkflow } from "../../types/workflow/Workflow.type"; import { getFunctionName } from "../internal"; +import { Settings } from "../../utils/Settings.util"; -export default class WorkflowClient { +export default class DaprWorkflowClient { private readonly _innerClient: TaskHubGrpcClient; /** @@ -30,11 +31,14 @@ export default class WorkflowClient { this._innerClient = this.buildInnerClient(hostAddress, options); } - private buildInnerClient(hostAddress = "127.0.0.1:50001", options: grpc.ChannelOptions = {}): TaskHubGrpcClient { + private buildInnerClient(hostAddress?: string, options: grpc.ChannelOptions = {}): TaskHubGrpcClient { const innerOptions = { ...options, interceptors: [generateInterceptors(), ...(options?.interceptors ?? [])], }; + if (hostAddress === undefined) { + hostAddress = Settings.getDefaultHost() + ":" + Settings.getDefaultGrpcPort(); + } return new TaskHubGrpcClient(hostAddress, innerOptions); } diff --git a/src/workflow/runtime/WorkflowContext.ts b/src/workflow/runtime/WorkflowContext.ts index 137c16cf..8b04febb 100644 --- a/src/workflow/runtime/WorkflowContext.ts +++ b/src/workflow/runtime/WorkflowContext.ts @@ -13,14 +13,13 @@ limitations under the License. import { OrchestrationContext } from "@microsoft/durabletask-js"; import { Task } from "@microsoft/durabletask-js/task/task"; -import { TInput } from "@microsoft/durabletask-js/types/input.type"; -import { TOutput } from "@microsoft/durabletask-js/types/output.type"; import { TWorkflowActivity } from "../../types/workflow/Activity.type"; import { TWorkflow } from "../../types/workflow/Workflow.type"; import { getFunctionName } from "../internal"; import { WhenAllTask } from "@microsoft/durabletask-js/task/when-all-task"; import { whenAll, whenAny } from "@microsoft/durabletask-js/task"; import { WhenAnyTask } from "@microsoft/durabletask-js/task/when-any-task"; +import { TInput, TOutput } from "../../types/workflow/InputOutput.type"; export default class WorkflowContext { private readonly _innerContext: OrchestrationContext; diff --git a/src/workflow/runtime/WorkflowRuntime.ts b/src/workflow/runtime/WorkflowRuntime.ts index 8952a30c..967db918 100644 --- a/src/workflow/runtime/WorkflowRuntime.ts +++ b/src/workflow/runtime/WorkflowRuntime.ts @@ -49,7 +49,7 @@ export default class WorkflowRuntime { /** * Registers a Workflow implementation for handling orchestrations with a given name. * The name provided need not be same as workflow name. - * + * * @param {string} name - The name or identifier for the registered Workflow. * @param {TWorkflow} workflow - The instance of the Workflow class being registered. */ diff --git a/test/e2e/workflow/workflow.test.ts b/test/e2e/workflow/workflow.test.ts index 89b1ee0b..096bc871 100644 --- a/test/e2e/workflow/workflow.test.ts +++ b/test/e2e/workflow/workflow.test.ts @@ -11,7 +11,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import WorkflowClient from "../../../src/workflow/client/WorkflowClient"; +import DaprWorkflowClient from "../../../src/workflow/client/WorkflowClient"; import WorkflowContext from "../../../src/workflow/runtime/WorkflowContext"; import WorkflowRuntime from "../../../src/workflow/runtime/WorkflowRuntime"; import { TWorkflow } from "../../../src/types/workflow/Workflow.type"; @@ -22,12 +22,12 @@ import { Task } from "@microsoft/durabletask-js/task/task"; describe("Workflow", () => { const grpcEndpoint = "localhost:4001"; - let workflowClient: WorkflowClient; + let workflowClient: DaprWorkflowClient; let workflowRuntime: WorkflowRuntime; beforeEach(async () => { // Start a worker, which will connect to the sidecar in a background thread - workflowClient = new WorkflowClient(grpcEndpoint); + workflowClient = new DaprWorkflowClient(grpcEndpoint); workflowRuntime = new WorkflowRuntime(grpcEndpoint); });