# `Arcadic.Transport.Grpc`
[🔗](https://github.com/baselabs/arcadic/blob/baselabs_arcadic-v4.0.1/lib/arcadic/transport/grpc.ex#L6)

Executes queries, transactions, and data operations through ArcadeDB's
optional gRPC plugin (`GrpcServerPlugin`).

The server runs a streaming query once and sends batches as the caller
consumes the stream. Session-scoped requests carry a transaction ID.
Use HTTP for server settings, user administration, login, and logout.

## Selecting it

    conn =
      Arcadic.connect("grpc://localhost:50051", "mydb",
        transport: Arcadic.Transport.Grpc,
        auth: {"root", System.fetch_env!("PW")}
      )

Requires the optional dependency `{:protobuf, "~> 0.17.1"}`. The endpoint
comes from `Arcadic.Conn`. Use username and password authentication.
Admin RPCs authenticate with credentials in the request, and data RPCs
also send ArcadeDB's authentication metadata.

## Deadlines

The per-call or connection-level `:timeout` sets a monotonic RPC deadline.
Unary calls default to ten seconds. Streams default to an unbounded
deadline. The client retries a transient connection failure once before
sending a request.

## Cursors, ingest, and pooling

A cursor opens a dedicated connection on its first pull. Its owner handles
HTTP/2 keepalives even while the consumer pauses. Unread decoded batches
have a 16 MiB default budget, configurable with `:max_buffer_bytes`.
Exceeding it cancels the RPC and returns `:cursor_buffer_exceeded` on the next
pull. An early halt also cancels the RPC and closes the connection. Connect
failures raise at enumeration. A failure after dispatch yields an error
element. Client-streamed ingest also uses a dedicated connection and
writes within both HTTP/2 send windows.

Add `{Arcadic.Transport.Grpc.ChannelPool, []}` to share one multiplexed
connection for unary calls per endpoint and TLS trust configuration.
Without a pool, each unary call opens a connection.

## TLS

Use `grpcs://`, `grpc+tls://`, `https://`, or
`transport_options: [tls: true]` to enable TLS. Mint verifies the server
certificate and hostname. It uses the OS trust store unless you configure
`:cacertfile` or `:cacerts`.

## Errors and values

The transport classifies terminal gRPC statuses and exception-class
trailers as described in `Arcadic.Error`. It discards the raw description
and value-bearing trailers. Arcadic telemetry reports structure only.
A reply lost or rejected by the client after dispatch yields
`:outcome_unknown`. See `Arcadic.TransportError`.

Protobuf requests, response frames, and decompressed messages are capped
at 16 MiB per message. Values outside the wire type, such as a non-UTF-8
string or an integer outside int64, are rejected before encoding. DECIMAL
values decode to `Decimal` with the server's precision and scale.

`batch_ingest` uses ArcadeDB's `GraphBatchLoad` RPC. See `Arcadic.Bulk` for
transaction boundaries and partial progress.

---

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