grpc v0.3.1 GRPC.Server.Supervisor 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.Server, 50051}])
    ]

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

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor

Return a child_spec to start server

Callback invoked to start the supervisor and during hot code upgrades

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function child_spec(servers, port, opts \\ []) View Source
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
Link to this function init(arg) View Source
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 invoked to start the supervisor and during hot code upgrades.

Developers typically invoke Supervisor.init/2 at the end of their init callback to return the proper supervision flags.

Callback implementation for Supervisor.init/1.