# `BroadwayCloudPubSub.Pull.Client`
[🔗](https://github.com/dashbitco/broadway_cloud_pub_sub/blob/v2.0.0-rc.0/lib/broadway_cloud_pub_sub/pull/client.ex#L1)

A generic behaviour to implement Pub/Sub Clients for `BroadwayCloudPubSub.Pull.Producer`.

This module defines callbacks to normalize options and receive messages
from a Cloud Pub/Sub topic. Modules that implement this behaviour should be passed
as the `:client` option from `BroadwayCloudPubSub.Pull.Producer`.

# `ack_deadline`

```elixir
@type ack_deadline() :: 0..600
```

The amount of time (in seconds) before Pub/Sub should reschedule a message.

# `ack_id`

```elixir
@type ack_id() :: String.t()
```

The `ackId` returned by Pub/Sub to be used when acknowledging a message.

# `ack_ids`

```elixir
@type ack_ids() :: [ack_id()]
```

A list of `ackId` strings.

# `messages`

```elixir
@type messages() :: [Broadway.Message.t()]
```

A list of `Broadway.Message` structs.

# `acknowledge`
*optional* 

```elixir
@callback acknowledge(ack_ids(), opts :: any()) :: any()
```

Dispatches an [`acknowledge`](https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/acknowledge) request.

# `init`

```elixir
@callback init(opts :: any()) ::
  {:ok, normalized_opts :: any()} | {:error, message :: binary()}
```

# `prepare_to_connect`
*optional* 

```elixir
@callback prepare_to_connect(name :: atom(), producer_opts :: keyword()) ::
  {[:supervisor.child_spec() | {module(), any()} | module()],
   producer_opts :: keyword()}
```

Invoked once by BroadwayCloudPubSub.Producer during `Broadway.start_link/2`.

The goal of this task is to manipulate the producer options,
if necessary at all, and introduce any new child specs that will be
started in Broadway's supervision tree.

# `put_deadline`
*optional* 

```elixir
@callback put_deadline(ack_ids(), ack_deadline(), opts :: any()) :: any()
```

Dispatches a [`modifyAckDeadline`](https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/modifyAckDeadline) request.

# `receive_messages`

```elixir
@callback receive_messages(
  demand :: pos_integer(),
  ack_builder :: (ack_id() -&gt; term()),
  opts :: any()
) ::
  messages()
```

Dispatches a [`pull`](https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions/pull) request.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
