Nostr.RelayPool (nostr_access v0.3.4)

View Source

Manages a pool of connections to a single relay.

Summary

Functions

Checks in a connection after use.

Checks out a connection with a free slot.

Returns a specification to start this module under a supervisor.

Starts a relay pool for the given URI.

Functions

checkin_conn(pool_pid, conn_pid)

@spec checkin_conn(pid(), pid()) :: :ok

Checks in a connection after use.

checkout_conn(pool_pid, opts \\ [])

@spec checkout_conn(
  pid(),
  keyword()
) :: {:ok, pid()} | {:error, :no_slot} | {:error, {:connection_failed, term()}}

Checks out a connection with a free slot.

Options

  • :force_new - when true, open a new WebSocket if under the pool limit instead of reusing an existing connection (default: false)

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(uri)

@spec start_link(String.t()) :: {:ok, pid()} | {:error, term()}

Starts a relay pool for the given URI.