# `Bourse.WS.ConnectionOwner`
[🔗](https://github.com/ZenHive/bourse/blob/main/lib/bourse/ws/connection_owner.ex#L1)

Holds the routed-host WebSocket clients for one `Bourse.WS` connection.

Owners start under `Bourse.WS.ConnectionOwner.Supervisor` (`:temporary`) and
are linked to the process that opened the `Bourse.WS` connection. Stopping or
crashing an owner closes every socket it still holds, so a dead owner cannot
leave an unreachable routed host, and an owner whose process dies is visible
to its dependents.

# `checkout`

```elixir
@spec checkout(
  pid(),
  (String.t(), keyword() -&gt; {:ok, ZenWebsocket.Client.t()} | {:error, term()}),
  String.t(),
  keyword(),
  timeout()
) :: {:ok, ZenWebsocket.Client.t()} | {:error, term()}
```

Returns the client for `url`, connecting through `connect_fun` when it is new.

# `child_spec`

```elixir
@spec child_spec({String.t(), ZenWebsocket.Client.t()}) :: Supervisor.child_spec()
```

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `start`

```elixir
@spec start(String.t(), ZenWebsocket.Client.t()) :: {:ok, pid()} | {:error, term()}
```

Starts a supervised owner holding `zen_client` at `url`.

# `stop`

```elixir
@spec stop(pid(), timeout()) :: :ok
```

Stops the owner. Remaining clients are closed from `terminate/2`.

# `take`

```elixir
@spec take(pid(), timeout()) :: {:ok, [ZenWebsocket.Client.t()]} | {:error, term()}
```

Removes and returns every held client so the caller can close them.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
