GRPC.Client.Adapters.Gun.ConnectionProcess (gRPC Client v1.0.0)

Copy Markdown View Source

Owns long-lived Gun connections on behalf of the Gun adapter.

This process exists so named Gun-backed channels are no longer tied to the lifecycle of the process that happened to call GRPC.Stub.connect/2.

Without this wrapper, GRPC.Client.Connection would need to own Gun directly or understand Gun-specific owner messages. Keeping Gun ownership in this adapter-local process preserves a clean adapter boundary while ensuring the underlying Gun connection survives short-lived callers.

Request-specific Gun messages are routed to per-stream response processes, so this process only needs to manage connection-level lifecycle and stream bookkeeping.

Summary

Functions

cancel(connection_process_pid, stream_ref)

@spec cancel(pid(), reference()) :: :ok

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

connect(channel, open_opts)

@spec connect(GRPC.Channel.t(), map()) :: {:ok, %{conn_pid: pid()}} | {:error, any()}

disconnect(connection_process_pid)

@spec disconnect(pid()) :: :ok

open_stream(connection_process_pid, path, headers)

@spec open_stream(pid(), iodata(), list()) ::
  {:ok, %{stream_ref: reference(), response_pid: pid()}} | {:error, any()}

request(connection_process_pid, path, headers, body)

@spec request(pid(), iodata(), list(), iodata()) ::
  {:ok, %{stream_ref: reference(), response_pid: pid()}} | {:error, any()}

send_data(connection_process_pid, stream_ref, fin, data)

@spec send_data(pid(), reference(), :fin | :nofin, iodata()) :: :ok

start_link(channel, open_opts)

@spec start_link(GRPC.Channel.t(), map()) :: GenServer.on_start()