-
Notifications
You must be signed in to change notification settings - Fork 50
/
sayHello.ts
49 lines (39 loc) · 1.84 KB
/
sayHello.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import * as df from "durable-functions";
import { ActivityHandler, OrchestrationContext, OrchestrationHandler } from "durable-functions";
const helloActivityName = "sayHello";
const helloSequence: OrchestrationHandler = function* (context: OrchestrationContext) {
context.log("Starting chain sample");
const output: string[] = [];
output.push(yield context.df.callActivity(helloActivityName, "Tokyo"));
output.push(yield context.df.callActivity(helloActivityName, "Seattle"));
output.push(yield context.df.callActivity(helloActivityName, "Cairo"));
return output;
};
df.app.orchestration("helloSequence", helloSequence);
const sayHelloWithActivity: OrchestrationHandler = function* (context: OrchestrationContext) {
const input: unknown = context.df.getInput();
const output: string = yield context.df.callActivity(helloActivityName, input);
return output;
};
df.app.orchestration("sayHelloWithActivity", sayHelloWithActivity);
const sayHelloWithCustomStatus: OrchestrationHandler = function* (context: OrchestrationContext) {
const input: unknown = context.df.getInput();
const output: string = yield context.df.callActivity(helloActivityName, input);
context.df.setCustomStatus(output);
return output;
};
df.app.orchestration("sayHelloWithCustomStatus", sayHelloWithCustomStatus);
const sayHelloWithSubOrchestrator: OrchestrationHandler = function* (
context: OrchestrationContext
) {
const input: unknown = context.df.getInput();
const output: string = yield context.df.callSubOrchestrator("sayHelloWithActivity", { input });
return output;
};
df.app.orchestration("sayHelloWithSubOrchestrator", sayHelloWithSubOrchestrator);
const helloActivity: ActivityHandler = function (input: unknown): string {
return `Hello ${input}`;
};
df.app.activity(helloActivityName, {
handler: helloActivity,
});