Skip to content

Commit 7f839a6

Browse files
authored
workflows: update durabletask fork and finish set custom status (#647)
* update durabletask dependency to use fork Signed-off-by: Fabian Martinez <46371672+famarting@users.noreply.github.com> * support set custom status Signed-off-by: Fabian Martinez <46371672+famarting@users.noreply.github.com> * lint Signed-off-by: Fabian Martinez <46371672+famarting@users.noreply.github.com> --------- Signed-off-by: Fabian Martinez <46371672+famarting@users.noreply.github.com>
1 parent 50f61af commit 7f839a6

File tree

15 files changed

+58
-40
lines changed

15 files changed

+58
-40
lines changed

examples/workflow/authoring/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/workflow/management/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 19 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
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.2",
51+
"@dapr/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/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import WorkflowActivityContext from "./workflow/runtime/WorkflowActivityContext"
4545
import WorkflowContext from "./workflow/runtime/WorkflowContext";
4646
import WorkflowRuntime from "./workflow/runtime/WorkflowRuntime";
4747
import { TWorkflow } from "./types/workflow/Workflow.type";
48-
import { Task } from "@microsoft/durabletask-js/task/task";
48+
import { Task } from "@dapr/durabletask-js/task/task";
4949
import { WorkflowFailureDetails } from "./workflow/client/WorkflowFailureDetails";
5050
import { WorkflowState } from "./workflow/client/WorkflowState";
5151
import {

src/types/workflow/Workflow.type.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ limitations under the License.
1212
*/
1313

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

1818
/**

src/workflow/client/DaprWorkflowClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ See the License for the specific language governing permissions and
1111
limitations under the License.
1212
*/
1313

14-
import { TaskHubGrpcClient } from "@microsoft/durabletask-js";
14+
import { TaskHubGrpcClient } from "@dapr/durabletask-js";
1515
import { WorkflowState } from "./WorkflowState";
1616
import { generateApiTokenClientInterceptors, generateEndpoint, getDaprApiToken } from "../internal/index";
1717
import { TWorkflow } from "../../types/workflow/Workflow.type";

src/workflow/client/WorkflowFailureDetails.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ See the License for the specific language governing permissions and
1111
limitations under the License.
1212
*/
1313

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

1616
/**
1717
* Class that represents the details of a task failure.

src/workflow/client/WorkflowState.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ See the License for the specific language governing permissions and
1111
limitations under the License.
1212
*/
1313

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

@@ -105,4 +105,12 @@ export class WorkflowState {
105105
public get workflowFailureDetails(): WorkflowFailureDetails | undefined {
106106
return this._workflowFailureDetails;
107107
}
108+
109+
/**
110+
* Gets the workflow instance's custom status, if any, as a string value.
111+
* @returns {string | undefined} The workflow instance's custom status or undefined.
112+
*/
113+
public get customStatus(): string | undefined {
114+
return this._orchestrationState.serializedCustomStatus;
115+
}
108116
}

src/workflow/runtime/WorkflowActivityContext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ See the License for the specific language governing permissions and
1111
limitations under the License.
1212
*/
1313

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

1616
/**
1717
* Used by activity to perform actions such as getting activity's name and

src/workflow/runtime/WorkflowContext.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ See the License for the specific language governing permissions and
1111
limitations under the License.
1212
*/
1313

14-
import { OrchestrationContext } from "@microsoft/durabletask-js";
15-
import { Task } from "@microsoft/durabletask-js/task/task";
14+
import { OrchestrationContext } from "@dapr/durabletask-js";
15+
import { Task } from "@dapr/durabletask-js/task/task";
1616
import { TWorkflowActivity } from "../../types/workflow/Activity.type";
1717
import { TWorkflow } from "../../types/workflow/Workflow.type";
1818
import { getFunctionName } from "../internal";
19-
import { WhenAllTask } from "@microsoft/durabletask-js/task/when-all-task";
20-
import { whenAll, whenAny } from "@microsoft/durabletask-js/task";
21-
import { WhenAnyTask } from "@microsoft/durabletask-js/task/when-any-task";
19+
import { WhenAllTask } from "@dapr/durabletask-js/task/when-all-task";
20+
import { whenAll, whenAny } from "@dapr/durabletask-js/task";
21+
import { WhenAnyTask } from "@dapr/durabletask-js/task/when-any-task";
2222
import { TInput, TOutput } from "../../types/workflow/InputOutput.type";
2323

2424
/**
@@ -156,6 +156,15 @@ export default class WorkflowContext {
156156
this._innerContext.continueAsNew(newInput, saveEvents);
157157
}
158158

159+
/**
160+
* Sets the custom status
161+
*
162+
* @param status {string} The new custom status
163+
*/
164+
public setCustomStatus(status: string): void {
165+
this._innerContext.setCustomStatus(status);
166+
}
167+
159168
/**
160169
* Returns a task that completes when all of the provided tasks complete or when one of the tasks fail
161170
*

src/workflow/runtime/WorkflowRuntime.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ See the License for the specific language governing permissions and
1111
limitations under the License.
1212
*/
1313

14-
import { ActivityContext, OrchestrationContext, TaskHubGrpcWorker } from "@microsoft/durabletask-js";
14+
import { ActivityContext, OrchestrationContext, TaskHubGrpcWorker } from "@dapr/durabletask-js";
1515
import { TWorkflow } from "../../types/workflow/Workflow.type";
1616
import { TWorkflowActivity } from "../../types/workflow/Activity.type";
1717
import { TInput, TOutput } from "../../types/workflow/InputOutput.type";

src/workflow/runtime/WorkflowRuntimeStatus.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ See the License for the specific language governing permissions and
1111
limitations under the License.
1212
*/
1313

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

1616
/**
1717
* Enum describing the runtime status of a workflow.

test/e2e/workflow/workflow.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { TWorkflow } from "../../../src/types/workflow/Workflow.type";
1818
import { getFunctionName } from "../../../src/workflow/internal";
1919
import { WorkflowRuntimeStatus } from "../../../src/workflow/runtime/WorkflowRuntimeStatus";
2020
import WorkflowActivityContext from "../../../src/workflow/runtime/WorkflowActivityContext";
21-
import { Task } from "@microsoft/durabletask-js/task/task";
21+
import { Task } from "@dapr/durabletask-js/task/task";
2222

2323
const clientHost = "localhost";
2424
const clientPort = "4001";
@@ -76,7 +76,7 @@ describe("Workflow", () => {
7676
current = yield ctx.callActivity(plusOne, current);
7777
numbers.push(current);
7878
}
79-
79+
ctx.setCustomStatus("foo");
8080
return numbers;
8181
};
8282

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

9899
it("should be able to run fan-out/fan-in", async () => {

test/unit/workflow/workflowRuntimeStatus.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ See the License for the specific language governing permissions and
1111
limitations under the License.
1212
*/
1313

14-
import { OrchestrationStatus } from "@microsoft/durabletask-js/orchestration/enum/orchestration-status.enum";
14+
import { OrchestrationStatus } from "@dapr/durabletask-js/orchestration/enum/orchestration-status.enum";
1515
import {
1616
WorkflowRuntimeStatus,
1717
fromOrchestrationStatus,

0 commit comments

Comments
 (0)