1import type * as sfn from "@distilled.cloud/aws/sfn";
2import type * as Effect from "effect/Effect";
3import * as Binding from "../../Binding.ts";
4import type { Activity } from "./Activity.ts";
5
6export interface GetActivityTaskRequest extends Omit<
7 sfn.GetActivityTaskInput,
8 "activityArn"
9> {}
10
11/**
12 * Runtime binding for `states:GetActivityTask` — the activity worker's
13 * long-poll. Bind this operation to an {@link Activity} inside a function
14 * runtime to receive scheduled activity tasks with the activity ARN
15 * injected automatically.
16 *
17 * The call blocks for up to 60 seconds when no task is scheduled (an empty
18 * `taskToken` means the poll timed out) — size the host's timeout
19 * accordingly. Complete the returned task with `SendTaskSuccess` /
20 * `SendTaskFailure`, keeping it alive with `SendTaskHeartbeat`.
21 * ### Activity Workers
22 * **Example:** Poll for a task and complete it
23 * ```typescript
24 * const getActivityTask = yield* StepFunctions.GetActivityTask(activity);
25 * const sendTaskSuccess = yield* StepFunctions.SendTaskSuccess(activity);
26 *
27 * const task = yield* getActivityTask({ workerName: "worker-1" });
28 * if (task.taskToken) {
29 * yield* sendTaskSuccess({
30 * taskToken: task.taskToken,
31 * output: JSON.stringify({ handled: true }),
32 * });
33 * }
34 * ```
35 *
36 * @binding
37 */
38export interface GetActivityTask extends Binding.Service<
39 GetActivityTask,
40 "AWS.StepFunctions.GetActivityTask",
41 (
42 activity: Activity,
43 ) => Effect.Effect<
44 (
45 request?: GetActivityTaskRequest,
46 ) => Effect.Effect<sfn.GetActivityTaskOutput, sfn.GetActivityTaskError>
47 >
48> {}
49export const GetActivityTask = Binding.Service<GetActivityTask>(
50 "AWS.StepFunctions.GetActivityTask",
51);