Hyper.Cfg.Grpc (Hyper v0.1.0)

Copy Markdown View Source

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

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.

Summary

Functions

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

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

Types

t()

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

Functions

load()

@spec load() :: t()

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

server_options(config)

@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.