# `Hyper.Cfg.Grpc`
[🔗](https://github.com/harmont-dev/hyper/blob/main/lib/hyper/cfg/grpc.ex#L1)

gRPC server configuration, read from application env into a struct:

    config :hyper, Hyper.Cfg.Grpc,
      enabled: true,
      port: 50_051,
      cred: GRPC.Credential.new(ssl: [certfile: "/path/cert.pem", keyfile: "/path/key.pem"])

Fields:

  * `:enabled` -- whether the server starts. Defaults to `false`.
  * `:port` -- the listen port. Defaults to `50051`.
  * `:cred` -- a `GRPC.Credential` for TLS, or `nil` (the default) for
    plaintext.
  * `:adapter_opts` -- options forwarded to the server adapter, e.g.
    `[ip: {0, 0, 0, 0}]`.

Build the credential where you load your keys (e.g. `config/runtime.exs`);
Hyper never reads the filesystem on your behalf.

Each field also reads from the `[grpc]` table of `config.toml` when not set in
`config.exs`. There, `cred` is given as an inline table
`{ cert = "/path/cert.pem", key = "/path/key.pem" }`, which is coerced into a
`GRPC.Credential`.

> #### Co-located nodes {: .info}
>
> Every node binds `:port`. Running multiple nodes on one host (e.g. a local
> cluster) requires giving each a distinct port via its own config.

# `t`

```elixir
@type t() :: %Hyper.Cfg.Grpc{
  adapter_opts: keyword(),
  cred: GRPC.Credential.t() | nil,
  enabled: boolean(),
  port: :inet.port_number()
}
```

# `load`

```elixir
@spec load() :: t()
```

Load the gRPC server configuration: config.exs > [grpc] toml > defaults.

# `server_options`

```elixir
@spec server_options(t()) :: keyword()
```

The `GRPC.Server.Supervisor` options for this config: the endpoint and port,
plus the TLS credential and adapter options when set.

---

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