Search documentation of Plushie

# Plushie.Test.SessionPool.Multiplexed (Plushie v0.7.2)

Copy Markdown View Source

State and business logic for the shared-renderer session pool modes.

`:mock` and `:headless` run one renderer process that hosts many logical sessions. This module owns the registrations, pending replies, teardown tracking, and dispatch of replies back to the correct test process.

## Summary

### Types

request_id()

Request identifier attached to a message sent to the renderer.

session_id()

Internal session identifier assigned by `SessionPool`.

t()

Shared-renderer state for multiplexed test sessions.

### Functions

find_session_by_owner(state, pid, ref)
handle_port_data(raw_data, state, atom)
handle_renderer_exit(state)
register(state, session_id, caller_pid, monitor_ref)
release_session(state, session_id, req_id, format)
send_async(state, session_id, msg, format)
send_interact(state, session_id, msg, req_id, format)
send_sync(state, session_id, msg, req_id, response_type, from, format)
session_count(state)
unregister(state, session_id, req_id, from, format)

## Types

# request_id()

    @type request_id() :: String.t()

Request identifier attached to a message sent to the renderer.

# session_id()

    @type session_id() :: String.t()

Internal session identifier assigned by `SessionPool`.

# t()

    @type t() :: %Plushie.Test.SessionPool.Multiplexed{
      buffer: binary(),
      pending: %{
        required({session_id(), request_id()}) => {String.t(), GenServer.from()}
      },
      pending_close: %{required(session_id()) => :awaiting},
      port: port(),
      sessions: %{required(session_id()) => {pid(), reference()}}
    }

Shared-renderer state for multiplexed test sessions.

## Functions

# find_session_by_owner(state, pid, ref)

    @spec find_session_by_owner(t(), pid(), reference()) ::
      {session_id(), {pid(), reference()}} | nil

# handle_port_data(raw_data, state, atom)

    @spec handle_port_data(
      binary() | {:eol, binary()},
      t(),
      Plushie.Test.SessionPool.Transport.format()
    ) ::
      t()

# handle_renderer_exit(state)

    @spec handle_renderer_exit(t()) :: t()

# register(state, session_id, caller_pid, monitor_ref)

    @spec register(t(), session_id(), pid(), reference()) :: t()

# release_session(state, session_id, req_id, format)

    @spec release_session(
      t(),
      session_id(),
      request_id(),
      Plushie.Test.SessionPool.Transport.format()
    ) ::
      t()

# send_async(state, session_id, msg, format)

    @spec send_async(
      t(),
      session_id(),
      map(),
      Plushie.Test.SessionPool.Transport.format()
    ) :: t()

# send_interact(state, session_id, msg, req_id, format)

    @spec send_interact(
      t(),
      session_id(),
      map(),
      request_id(),
      Plushie.Test.SessionPool.Transport.format()
    ) ::
      {:ok, t()} | :error

# send_sync(state, session_id, msg, req_id, response_type, from, format)

    @spec send_sync(
      t(),
      session_id(),
      map(),
      request_id(),
      String.t(),
      GenServer.from(),
      Plushie.Test.SessionPool.Transport.format()
    ) :: {:ok, t()} | :error

# session_count(state)

    @spec session_count(t()) :: non_neg_integer()

# unregister(state, session_id, req_id, from, format)

    @spec unregister(
      t(),
      session_id(),
      request_id(),
      GenServer.from(),
      Plushie.Test.SessionPool.Transport.format()
    ) :: t()