-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path39-activity-task.ts
More file actions
26 lines (21 loc) · 865 Bytes
/
Copy path39-activity-task.ts
File metadata and controls
26 lines (21 loc) · 865 Bytes
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
// Activity Task
//
// Activity tasks use external workers that poll for work, process it, and
// send back results. The activity ARN is used directly as the Task Resource.
import { Steps, SimpleStepContext } from '../../packages/core/src/runtime/index';
import { Activity } from '../../packages/core/src/runtime/services/Activity';
const humanReview = Activity<{ document: string }, { approved: boolean }>(
'arn:aws:states:us-east-1:123456789012:activity:HumanReview'
);
export const activityWorkflow = Steps.createFunction(
async (context: SimpleStepContext, input: { document: string }) => {
const result = await humanReview.call(
{ document: input.document },
{ timeoutSeconds: 3600, heartbeatSeconds: 60 },
);
if (!result.approved) {
throw new Error('Document rejected');
}
return { status: 'approved' };
},
);