GRPC.Server.Supervisor (grpc v0.6.3-git-c634) View Source

A simple supervisor to start your servers.

You can add it to your OTP tree as below. But to make the servers start, you have to config grpc

defmodule Your.App do
  use Application

  def start(_type, _args) do
    import Supervisor.Spec

    children = [
      supervisor(GRPC.Server.Supervisor, [{Your.Endpoint, 50051(, opts)}])
    ]

    opts = [strategy: :one_for_one, name: __MODULE__]
    Supervisor.start_link(children, opts)
  end
end

# config.exs
config :grpc, start_server: true
or
run `mix grpc.server` on local

View child_spec/3 for opts.

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Return a child_spec to start server.

Callback implementation for Supervisor.init/1.

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

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

View Source

Specs

child_spec(atom() | [atom()], integer(), Keyword.t()) :: 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

Specs

init({module() | [module()], integer()}) ::
  {:ok, {:supervisor.sup_flags(), [:supervisor.child_spec()]}} | :ignore
init({module() | [module()], integer(), Keyword.t()}) ::
  {:ok, {:supervisor.sup_flags(), [:supervisor.child_spec()]}} | :ignore

Callback implementation for Supervisor.init/1.