# `Arcadic.Conn`
[🔗](https://github.com/baselabs/arcadic/blob/baselabs_arcadic-v4.0.1/lib/arcadic/conn.ex#L5)

Connection handle for ArcadeDB — pure data, no process.

HTTP has no per-connection state; Finch owns the socket pool and the ArcadeDB
session (when inside a transaction) rides `session_id`. Build one with
`Arcadic.connect/3`; derive a same-pool handle on another database with
`with_database/2`.

# `consistency`

```elixir
@type consistency() :: :eventual | :read_your_writes | :linearizable
```

# `t`

```elixir
@type t() :: %Arcadic.Conn{
  auth: {String.t(), String.t()} | {:bearer, String.t()},
  base_url: String.t(),
  consistency: consistency(),
  database: String.t(),
  hosts: [String.t()],
  migration_lease: :ets.tid() | nil,
  read_after: integer() | nil,
  request_timeout: pos_integer() | nil,
  session_id: String.t() | nil,
  timeout: pos_integer() | nil,
  transaction_progress: :atomics.atomics_ref() | nil,
  transport: module(),
  transport_options: keyword()
}
```

# `new`

```elixir
@spec new(String.t(), String.t(), keyword()) :: t()
```

Build a connection handle.

## Options
  * `:auth` — `{user, pass}`. REQUIRED (no default credential).
  * `:transport` — transport module (default `Arcadic.Transport.HTTP`).
  * `:transport_options` — keyword passed to the transport (`:finch`, `:plug`, `:timeout`, pool knobs).
  * `:timeout` — default per-call receive timeout (ms; max wait per received CHUNK).
  * `:request_timeout` — default per-call whole-response timeout (ms). Bounds the full
    response, defeating a peer that trickles chunks forever; `nil` (the default) leaves
    Finch's own default (`:infinity`) in place.
  * `:consistency` - read-consistency level: `:eventual` (default) | `:read_your_writes` |
    `:linearizable`. HTTP-only; a non-default level on a Bolt or gRPC conn raises.
  * `:hosts` - additional `http(s)` base URLs for multi-host availability failover
    (default `[]`). HTTP-only; a non-empty list on a Bolt or gRPC conn raises.

A `base_url` carrying USERINFO (e.g. `http://user:pass@host`) together with an explicit
`:auth` raises — the HTTP layer resolves that conflict silently (the URL credentials win
over the header), which would defeat a caller deliberately overriding credentials.

## Examples

    iex> Arcadic.connect("http://localhost:2480", "mydb", auth: {"root", "x"}).database
    "mydb"

# `with_bearer`

```elixir
@spec with_bearer(t(), String.t()) :: t()
```

Derive a Bearer-auth handle from a Basic one (typically after `Arcadic.Security.login/1`).

# `with_consistency`

```elixir
@spec with_consistency(t(), consistency()) :: t()
```

Derive a handle with a read-consistency level; validates and clears the session. HTTP-only.

# `with_database`

```elixir
@spec with_database(t(), String.t()) :: t()
```

Derive a same-pool handle on another database; validates and clears the session.

---

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