Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workflows: update durabletask fork and finish set custom status #647

Merged
merged 3 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/workflow/authoring/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions examples/workflow/management/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 19 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"dependencies": {
"@grpc/grpc-js": "^1.9.3",
"@js-temporal/polyfill": "^0.3.0",
"@microsoft/durabletask-js": "^0.1.0-alpha.2",
"@dapr/durabletask-js": "0.1.0-alpha.2",
"@types/google-protobuf": "^3.15.5",
"@types/node-fetch": "^2.6.2",
"body-parser": "^1.19.0",
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import WorkflowActivityContext from "./workflow/runtime/WorkflowActivityContext"
import WorkflowContext from "./workflow/runtime/WorkflowContext";
import WorkflowRuntime from "./workflow/runtime/WorkflowRuntime";
import { TWorkflow } from "./types/workflow/Workflow.type";
import { Task } from "@microsoft/durabletask-js/task/task";
import { Task } from "@dapr/durabletask-js/task/task";
import { WorkflowFailureDetails } from "./workflow/client/WorkflowFailureDetails";
import { WorkflowState } from "./workflow/client/WorkflowState";
import {
Expand Down
2 changes: 1 addition & 1 deletion src/types/workflow/Workflow.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ limitations under the License.
*/

import WorkflowContext from "../../workflow/runtime/WorkflowContext";
import { Task } from "@microsoft/durabletask-js/task/task";
import { Task } from "@dapr/durabletask-js/task/task";
import { TOutput } from "./InputOutput.type";

/**
Expand Down
2 changes: 1 addition & 1 deletion src/workflow/client/DaprWorkflowClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { TaskHubGrpcClient } from "@microsoft/durabletask-js";
import { TaskHubGrpcClient } from "@dapr/durabletask-js";
import { WorkflowState } from "./WorkflowState";
import { generateApiTokenClientInterceptors, generateEndpoint, getDaprApiToken } from "../internal/index";
import { TWorkflow } from "../../types/workflow/Workflow.type";
Expand Down
2 changes: 1 addition & 1 deletion src/workflow/client/WorkflowFailureDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { FailureDetails } from "@microsoft/durabletask-js/task/failure-details";
import { FailureDetails } from "@dapr/durabletask-js/task/failure-details";

/**
* Class that represents the details of a task failure.
Expand Down
10 changes: 9 additions & 1 deletion src/workflow/client/WorkflowState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { OrchestrationState } from "@microsoft/durabletask-js/orchestration/orchestration-state";
import { OrchestrationState } from "@dapr/durabletask-js/orchestration/orchestration-state";
import { WorkflowFailureDetails } from "./WorkflowFailureDetails";
import { WorkflowRuntimeStatus, fromOrchestrationStatus } from "../runtime/WorkflowRuntimeStatus";

Expand Down Expand Up @@ -105,4 +105,12 @@ export class WorkflowState {
public get workflowFailureDetails(): WorkflowFailureDetails | undefined {
return this._workflowFailureDetails;
}

/**
* Gets the workflow instance's custom status, if any, as a string value.
* @returns {string | undefined} The workflow instance's custom status or undefined.
*/
public get customStatus(): string | undefined {
return this._orchestrationState.serializedCustomStatus;
}
}
2 changes: 1 addition & 1 deletion src/workflow/runtime/WorkflowActivityContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { ActivityContext } from "@microsoft/durabletask-js";
import { ActivityContext } from "@dapr/durabletask-js";

/**
* Used by activity to perform actions such as getting activity's name and
Expand Down
19 changes: 14 additions & 5 deletions src/workflow/runtime/WorkflowContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { OrchestrationContext } from "@microsoft/durabletask-js";
import { Task } from "@microsoft/durabletask-js/task/task";
import { OrchestrationContext } from "@dapr/durabletask-js";
import { Task } from "@dapr/durabletask-js/task/task";
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 { WhenAllTask } from "@dapr/durabletask-js/task/when-all-task";
import { whenAll, whenAny } from "@dapr/durabletask-js/task";
import { WhenAnyTask } from "@dapr/durabletask-js/task/when-any-task";
import { TInput, TOutput } from "../../types/workflow/InputOutput.type";

/**
Expand Down Expand Up @@ -156,6 +156,15 @@ export default class WorkflowContext {
this._innerContext.continueAsNew(newInput, saveEvents);
}

/**
* Sets the custom status
*
* @param status {string} The new custom status
*/
public setCustomStatus(status: string): void {
this._innerContext.setCustomStatus(status);
}

/**
* Returns a task that completes when all of the provided tasks complete or when one of the tasks fail
*
Expand Down
2 changes: 1 addition & 1 deletion src/workflow/runtime/WorkflowRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { ActivityContext, OrchestrationContext, TaskHubGrpcWorker } from "@microsoft/durabletask-js";
import { ActivityContext, OrchestrationContext, TaskHubGrpcWorker } from "@dapr/durabletask-js";
import { TWorkflow } from "../../types/workflow/Workflow.type";
import { TWorkflowActivity } from "../../types/workflow/Activity.type";
import { TInput, TOutput } from "../../types/workflow/InputOutput.type";
Expand Down
2 changes: 1 addition & 1 deletion src/workflow/runtime/WorkflowRuntimeStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { OrchestrationStatus } from "@microsoft/durabletask-js/orchestration/enum/orchestration-status.enum";
import { OrchestrationStatus } from "@dapr/durabletask-js/orchestration/enum/orchestration-status.enum";

/**
* Enum describing the runtime status of a workflow.
Expand Down
5 changes: 3 additions & 2 deletions test/e2e/workflow/workflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { TWorkflow } from "../../../src/types/workflow/Workflow.type";
import { getFunctionName } from "../../../src/workflow/internal";
import { WorkflowRuntimeStatus } from "../../../src/workflow/runtime/WorkflowRuntimeStatus";
import WorkflowActivityContext from "../../../src/workflow/runtime/WorkflowActivityContext";
import { Task } from "@microsoft/durabletask-js/task/task";
import { Task } from "@dapr/durabletask-js/task/task";

const clientHost = "localhost";
const clientPort = "4001";
Expand Down Expand Up @@ -76,7 +76,7 @@ describe("Workflow", () => {
current = yield ctx.callActivity(plusOne, current);
numbers.push(current);
}

ctx.setCustomStatus("foo");
return numbers;
};

Expand All @@ -93,6 +93,7 @@ describe("Workflow", () => {
expect(state?.runtimeStatus).toEqual(WorkflowRuntimeStatus.COMPLETED);
expect(state?.serializedInput).toEqual(JSON.stringify(1));
expect(state?.serializedOutput).toEqual(JSON.stringify([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]));
expect(state?.customStatus).toEqual("foo");
}, 31000);

it("should be able to run fan-out/fan-in", async () => {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/workflow/workflowRuntimeStatus.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import { OrchestrationStatus } from "@microsoft/durabletask-js/orchestration/enum/orchestration-status.enum";
import { OrchestrationStatus } from "@dapr/durabletask-js/orchestration/enum/orchestration-status.enum";
import {
WorkflowRuntimeStatus,
fromOrchestrationStatus,
Expand Down
Loading