CliSubprocessCore.ProtocolSession (CliSubprocessCore v0.1.0)

Copy Markdown View Source

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

Summary

Functions

Waits for the protocol session to become ready.

Returns a specification to start this module under a supervisor.

Stops the protocol session.

Returns protocol-session information.

Interrupts the underlying channel.

Sends an outbound protocol notification.

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

Starts an unlinked protocol session.

Starts a linked protocol session.

Types

info_t()

@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()

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

t()

@type t() :: pid()

Functions

await_ready(session, timeout_ms)

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

Waits for the protocol session to become ready.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

close(session)

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

Stops the protocol session.

info(session)

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

Returns protocol-session information.

interrupt(session)

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

Interrupts the underlying channel.

notify(session, notification)

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

Sends an outbound protocol notification.

request(session, request, opts \\ [])

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

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

start(opts)

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

Starts an unlinked protocol session.

start_link(opts)

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

Starts a linked protocol session.