GrpcConnectionPool.Worker (grpc_connection_pool v0.3.5)

Copy Markdown View Source

GenServer-based gRPC connection worker with automatic reconnection.

Each worker manages a single gRPC connection and stores its channel directly in the pool's ETS table for zero-GenServer-call access from Pool.get_channel/1.

Features:

  • Channels stored in ETS for O(1) pool access (no GenServer.call in hot path)
  • Automatic reconnection with exponential backoff and jitter
  • Active disconnect detection (gun_down/gun_error messages)
  • Self-registration in Registry for health tracking
  • Optional periodic ping to keep connections warm
  • Configurable max reconnect attempts before crash

Summary

Functions

Returns a specification to start this module under a supervisor.

Starts a connection worker.

Gets the current connection status.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(opts)

@spec start_link(keyword()) :: GenServer.on_start()

Starts a connection worker.

Options:

  • :config — GrpcConnectionPool.Config struct (required)
  • :registry_name — Registry name for self-registration (required)
  • :pool_name — Pool name for telemetry (required)

status(worker)

@spec status(pid()) :: :connected | :disconnected

Gets the current connection status.