zio.blocks.mux

package zio.blocks.mux

Members list

Type members

Classlikes

case object BuildInfo

This object was generated by sbt-buildinfo.

This object was generated by sbt-buildinfo.

Attributes

Source
BuildInfo.scala
Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Self type
BuildInfo.type
trait Mux[Id, In, Out]

A multiplexer that manages multiple independent streams over a shared transport.

A multiplexer that manages multiple independent streams over a shared transport.

Each stream is identified by a unique Id and has independent inbound/outbound message queues. The multiplexer enforces a maximum number of concurrent streams (capacity). Attempting to open a stream beyond that limit returns MuxError.CapacityExceeded.

'''Invariants:'''

  • Stream IDs must be unique among active streams; opening a duplicate returns MuxError.ProtocolError.
  • capacity is fixed at construction and never changes.
  • After closeAll, no new streams can be opened (MuxError.MuxClosed is returned) and all previously active streams transition to CLOSED with the supplied error enqueued for any pending receive.

'''Thread safety:''' open, get, cancel, closeAll, and activeCount are safe to call from multiple threads concurrently. Per-stream operations on MuxStream: send and offerInbound are multi-thread safe. receive and takeOutbound must each be called from a single consumer thread at a time (single-consumer contract of the underlying ring buffer).

Type parameters

Id

Stream identifier type (e.g., Int for HTTP/2 stream IDs)

In

Message type sent on streams (outbound from user code)

Out

Message type received on streams (inbound to user code)

Attributes

Companion
object
Source
Mux.scala
Supertypes
class Object
trait Matchable
class Any
object Mux

Multiplexer for ID-multiplexed protocols (HTTP/2, QUIC, etc.).

Multiplexer for ID-multiplexed protocols (HTTP/2, QUIC, etc.).

Manages multiple concurrent streams, each identified by a unique ID. Streams are independent and can be opened, closed, or cancelled independently.

Type parameters

Id

Stream identifier type (e.g., Int for HTTP/2)

In

Message type sent on streams

Out

Message type received on streams

Attributes

Companion
trait
Source
Mux.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Mux.type
sealed trait MuxError

Error type for Mux operations.

Error type for Mux operations.

The id field in MuxError.StreamClosed and MuxError.Cancelled is typed as Any to keep MuxError non-generic. Parameterizing the sealed hierarchy on the stream ID type would make pattern matching and error handling unwieldy across different Mux instances. Callers can recover the concrete ID type via pattern matching at the use site.

Attributes

Companion
object
Source
MuxError.scala
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Cancelled
object MuxClosed
class QueueFull
class StreamClosed
Show all
object MuxError

Attributes

Companion
trait
Source
MuxError.scala
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
MuxError.type
trait MuxStream[Id, In, Out]

Individual stream within a Mux.

Individual stream within a Mux.

Encapsulates the state machine for a single stream (IDLE, OPEN, HALF_CLOSED_LOCAL, HALF_CLOSED_REMOTE, CLOSED). Provides send/receive operations and state queries.

This stream has two separate message queues:

  • '''Outbound queue''': messages sent by user code via send(), drained by the mux/protocol via takeOutbound()
  • '''Inbound queue''': messages delivered by the mux/protocol via offerInbound(), read by user code via receive()

Type parameters

Id

Stream identifier type

In

Message type sent on this stream

Out

Message type received on this stream

Attributes

Source
Mux.scala
Supertypes
class Object
trait Matchable
class Any