Skip to content

Commit 56b1414

Browse files
Add support for asyncComplete flag in http task (#77)
* support for asyncComplete flag for http task * add waitForWorkflowStatus util usage, remove type * Update executor.test.ts * update gh workflow vars
1 parent 06b31bb commit 56b1414

6 files changed

Lines changed: 44 additions & 5 deletions

File tree

.github/workflows/pull_request.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ jobs:
3131
- name: Run Tests
3232
run: yarn test --ci --reporters=default --reporters=jest-junit
3333
env:
34-
CONDUCTOR_SERVER_URL: ${{ secrets.SERVER_URL }}
35-
CONDUCTOR_AUTH_KEY: ${{ secrets.KEY_ID }}
36-
CONDUCTOR_AUTH_SECRET: ${{ secrets.KEY_SECRET }}
34+
CONDUCTOR_SERVER_URL: ${{ vars.SERVER_URL }}
35+
CONDUCTOR_AUTH_KEY: ${{ secrets.AUTH_KEY }}
36+
CONDUCTOR_AUTH_SECRET: ${{ secrets.AUTH_SECRET }}
3737
- name: Publish Test Results
38-
if: always()
38+
if: always()
3939
uses: dorny/test-reporter@v2
4040
with:
4141
name: Test report

src/common/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ export interface HttpTaskDef extends CommonTaskDef {
119119
http_request: HttpInputParameters;
120120
};
121121
type: TaskType.HTTP;
122+
asyncComplete?: boolean;
122123
}
123124

124125
export interface InlineTaskInputParameters {

src/core/__test__/executor.test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import {MetadataClient} from "../metadataClient";
77
import {TestUtil} from "./utils/test-util";
88
import {TaskResultStatusEnum} from "../../common/open-api/models/TaskResultStatusEnum";
99
import {SignalResponse} from "../../common/open-api/models/SignalResponse";
10+
import { httpTask } from "../sdk";
11+
import { TaskClient } from "../taskClient";
1012

1113
describe("Executor", () => {
1214
const clientPromise = orkesConductorClient({ useEnvVars: true });
@@ -111,6 +113,38 @@ describe("Executor", () => {
111113
const executionDetails = await executor.getWorkflow(executionId!, true);
112114
expect(executionDetails.idempotencyKey).toEqual(idempotencyKey);
113115
});
116+
117+
test("Should run workflow with http task with asyncComplete true", async () => {
118+
const client = await clientPromise;
119+
const executor = new WorkflowExecutor(client);
120+
121+
await executor.registerWorkflow(true, {
122+
name: "test_jssdk_workflow_with_http_task_with_asyncComplete_true",
123+
version: 1,
124+
ownerEmail: "developers@orkes.io",
125+
tasks: [httpTask("test_jssdk_http_task_with_asyncComplete_true", { uri: "http://www.yahoo.com", method: "GET" }, true)],
126+
inputParameters: [],
127+
outputParameters: {},
128+
timeoutSeconds: 300,
129+
});
130+
131+
const executionId = await executor.startWorkflow({
132+
name: "test_jssdk_workflow_with_http_task_with_asyncComplete_true",
133+
input: {},
134+
version: 1,
135+
});
136+
137+
const workflowStatusBefore = await TestUtil.waitForWorkflowStatus(executor, executionId, "RUNNING");
138+
139+
expect(["IN_PROGRESS", "SCHEDULED"]).toContain(workflowStatusBefore.tasks?.[0]?.status);
140+
141+
const taskClient = new TaskClient(client);
142+
taskClient.updateTaskResult(executionId, "test_jssdk_http_task_with_asyncComplete_true", "COMPLETED", { hello: "From manuall api call updating task result" });
143+
144+
const workflowStatusAfter = await TestUtil.waitForWorkflowStatus(executor, executionId, "COMPLETED");
145+
146+
expect(workflowStatusAfter.tasks?.[0]?.status).toEqual("COMPLETED");
147+
});
114148
});
115149

116150
describe("Execute with Return Strategy and Consistency", () => {

src/core/generators/HttpTask.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const generateHTTPTask = (
1818
method: "GET",
1919
},
2020
},
21+
asyncComplete: false,
2122
...overrides,
2223
type: TaskType.HTTP,
2324
});

src/core/sdk/__test__/factory.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ describe("httpTask", () => {
150150
method: "GET",
151151
});
152152
expect(httpTaskObj).toEqual({
153+
asyncComplete: false,
153154
name: "httpTask",
154155
taskReferenceName: "httpTask",
155156
inputParameters: {

src/core/sdk/http.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ import {
66

77
export const httpTask = (
88
taskReferenceName: string,
9-
inputParameters: HttpInputParameters
9+
inputParameters: HttpInputParameters,
10+
asyncComplete = false
1011
): HttpTaskDef => ({
1112
name: taskReferenceName,
1213
taskReferenceName,
1314
inputParameters: {
1415
http_request: inputParameters,
1516
},
17+
asyncComplete,
1618
type: TaskType.HTTP,
1719
});

0 commit comments

Comments
 (0)