# `CliSubprocessCore.ProtocolSession`
[🔗](https://github.com/nshkrdotcom/cli_subprocess_core/blob/v0.1.0/lib/cli_subprocess_core/protocol_session.ex#L1)

Generic protocol-session runtime above `CliSubprocessCore.Channel`.

The session owns:

- channel lifecycle
- readiness state
- startup timeout
- outbound request tracking
- inbound peer-request tracking
- peer-request handler dispatch
- request timeouts
- close and interrupt normalization

# `info_t`

```elixir
@type info_t() :: %{
  adapter: module(),
  phase: :starting | :ready,
  ready_mode: ready_mode(),
  pending_requests: non_neg_integer(),
  pending_peer_requests: non_neg_integer(),
  channel: map() | %{}
}
```

# `ready_mode`

```elixir
@type ready_mode() :: :immediate | :startup_complete | :adapter_event
```

# `t`

```elixir
@type t() :: pid()
```

# `await_ready`

```elixir
@spec await_ready(pid(), pos_integer()) :: :ok | {:error, term()}
```

Waits for the protocol session to become ready.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `close`

```elixir
@spec close(pid()) :: :ok
```

Stops the protocol session.

# `info`

```elixir
@spec info(pid()) :: info_t() | %{}
```

Returns protocol-session information.

# `interrupt`

```elixir
@spec interrupt(pid()) :: :ok | {:error, term()}
```

Interrupts the underlying channel.

# `notify`

```elixir
@spec notify(pid(), term()) :: :ok | {:error, term()}
```

Sends an outbound protocol notification.

# `request`

```elixir
@spec request(pid(), term(), keyword()) :: {:ok, term()} | {:error, term()}
```

Sends an outbound protocol request and waits for the correlated reply.

# `start`

```elixir
@spec start(keyword()) :: {:ok, t()} | {:error, term()}
```

Starts an unlinked protocol session.

# `start_link`

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

Starts a linked protocol session.

---

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