1import type * as pubsub from "@distilled.cloud/gcp/pubsub_v1";
2import type * as Effect from "effect/Effect";
3import * as Binding from "../../Binding.ts";
4import type { RuntimeContext } from "../../RuntimeContext.ts";
5import type { Subscription } from "./Subscription.ts";
6
7export interface PullRequest extends Omit<
8 pubsub.PullProjectsSubscriptionsRequest,
9 "subscription"
10> {}
11
12/**
13 * Runtime binding for Pub/Sub `subscriptions.pull`.
14 *
15 * Bind this operation to a {@link Subscription} in a Function/Action init
16 * phase. Provide {@link PullHttp}.
17 *
18 * ### Pulling Messages
19 * **Example:** Pull messages
20 * ```typescript
21 * const pull = yield* GCP.PubSub.Pull(subscription);
22 * const { receivedMessages } = yield* pull({
23 * body: { maxMessages: 10 },
24 * });
25 * ```
26 *
27 * @binding
28 * @category PubSub
29 */
30export interface Pull extends Binding.Service<
31 Pull,
32 "GCP.PubSub.Pull",
33 (
34 subscription: Subscription,
35 ) => Effect.Effect<
36 (
37 request: PullRequest,
38 ) => Effect.Effect<
39 pubsub.PullResponse,
40 pubsub.PullProjectsSubscriptionsError,
41 RuntimeContext
42 >
43 >
44> {}
45
46export const Pull = Binding.Service<Pull>("GCP.PubSub.Pull");