View Source GRPC.Server.Supervisor (grpc v0.9.0)

A simple supervisor to start your servers.

You can add it to your OTP tree as below. To start the server, you can pass start_server: true and an option

defmodule Your.App do
  use Application

  def start(_type, _args) do
    children = [
      {GRPC.Server.Supervisor, endpoint: Your.Endpoint, port: 50051, start_server: true, ...}]

    Supervisor.start_link(children, strategy: :one_for_one, name: __MODULE__)
  end
end

Summary

Functions

Returns a specification to start this module under a supervisor.

Return a child_spec to start server.

Options

  • :endpoint - defines the endpoint module that will be started.
  • :port - the HTTP port for the endpoint.
  • :servers - the list of servers that will be be started.

Either :endpoint or :servers must be present, but not both.

Types

@type sup_flags() :: %{
  strategy: Supervisor.strategy(),
  intensity: non_neg_integer(),
  period: pos_integer(),
  auto_shutdown: Supervisor.auto_shutdown()
}

Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

child_spec(endpoint_or_servers, port, opts \\ [])

View Source
@spec child_spec(
  endpoint_or_servers :: atom() | [atom()],
  port :: integer(),
  opts :: keyword()
) ::
  Supervisor.Spec.spec()

Return a child_spec to start server.

Options

  • :cred - a credential created by functions of GRPC.Credential, an insecure server will be created without this option
  • :start_server - determines if the server will be started. If present, has more precedence then the config :gprc, :start_server config value (i.e. start_server: false will not start the server in any case).
@spec init(tuple()) :: no_return()
@spec init(keyword()) :: {:ok, {sup_flags(), [Supervisor.child_spec()]}} | :ignore

Options

  • :endpoint - defines the endpoint module that will be started.
  • :port - the HTTP port for the endpoint.
  • :servers - the list of servers that will be be started.

Either :endpoint or :servers must be present, but not both.