# `Electric.Postgres.ReplicationClient.ConnectionSetup`
[🔗](https://github.com/electric-sql/electric/tree/%40core/sync-service%401.6.2/packages/sync-service/lib/electric/postgres/replication_client/connection_setup.ex#L1)

This module encapsulates the initial setup of a replication connection opened by
`Electric.Postgres.ReplicationClient`.

A state machine is implemented to run a series of SQL queries prior to switching the
connection into the logical streaming mode. This helps keep the main `ReplicationClient`
module focused on the handling of logical messages.

# `callback_return`

```elixir
@type callback_return() ::
  {:noreply, state()}
  | {:query, iodata(), state()}
  | {:stream, iodata(), Electric.Postgres.ReplicationConnection.stream_opts(),
     state()}
```

# `extra_info`

```elixir
@type extra_info() :: term()
```

# `query_result`

```elixir
@type query_result() :: [Postgrex.Result.t()] | Postgrex.Error.t()
```

# `state`

```elixir
@type state() :: Electric.Postgres.ReplicationClient.State.t()
```

# `step`

```elixir
@type step() :: Electric.Postgres.ReplicationClient.step()
```

# `identify_system_result`

# `process_query_result`

```elixir
@spec process_query_result(query_result(), state()) ::
  {step(), step(), extra_info(), state(), callback_return()}
```

# `start`

```elixir
@spec start(state()) :: callback_return()
```

# `start_streaming`

```elixir
@spec start_streaming(state()) :: callback_return()
```

---

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