Dllb.Pool (Dllb v0.1.0)

Copy Markdown View Source

NimblePool-based connection pool for dllb TCP connections.

Workers are raw :gen_tcp sockets managed through Dllb.Connection. Dead sockets are detected at checkout and transparently reconnected.

Summary

Functions

Returns a child spec for starting the pool under a supervisor.

Executes a query through the connection pool.

Functions

child_spec(opts \\ [])

@spec child_spec(Keyword.t()) :: Supervisor.child_spec()

Returns a child spec for starting the pool under a supervisor.

Options

  • :host - server hostname (default from app env or "127.0.0.1")
  • :port - server port (default from app env or 3009)
  • :pool_size - number of connections (default from app env or 5)
  • :outcome - response format (default :json)
  • :timeout - connection/recv timeout in ms (default 30_000)

query(query_string, opts \\ [])

@spec query(String.t(), Keyword.t()) :: {:ok, Dllb.Result.t()} | {:error, term()}

Executes a query through the connection pool.

Checks out a socket, runs the query via Dllb.Connection.query/3, and checks the socket back in.

Options

  • :timeout - recv timeout in ms (default 30_000)

Returns {:ok, result} or {:error, reason}.