network-mux-0.1.0.1: Multiplexing library
Safe Haskell None
Language Haskell2010

Network.Mux.Ingress

Synopsis

Documentation

Ingress Path

                 ●
                 │
                 │ ByteStrings
                 │
        ░░░░░░░░░▼░░░░░░░░░
        ░┌───────────────┐░
        ░│ Bearer.read() │░ Mux Bearer implementation (Socket, Pipes, etc.)
        ░└───────────────┘░
        ░░░░░░░░░│░░░░░░░░░
                ░│░         MuxSDUs
        ░░░░░░░░░▼░░░░░░░░░
        ░┌───────────────┐░
        ░│     demux     │░ For a given Mux Bearer there is a single demux
        ░└───────┬───────┘░ thread reading from the underlying bearer.
        ░░░░░░░░░│░░░░░░░░░
                ░│░
       ░░░░░░░░░░▼░░░░░░░░░░
       ░ ╭────┬────┬─────╮ ░ There is a limited queue (in bytes) for each mode
       ░ │    │    │     │ ░ (responder/initiator) per miniprotocol. Overflowing
       ░ ▼    ▼    ▼     ▼ ░ a queue is a protocol violation and a
       ░│  │ │  │ │  │ │  │░ MuxIngressQueueOverRun exception is thrown
       ░│ci│ │  │ │bi│ │br│░ and the bearer torn down.
       ░│ci│ │cr│ │bi│ │br│░
       ░└──┘ └──┘ └──┘ └──┘░ Every ingress queue has a dedicated thread which will
       ░░│░░░░│░░░░│░░░░│░░░ read application encoded data from its queue.
         │    │    │    │
          application data
         │    │    │    │
         ▼    │    │    ▼
┌───────────┐ │    │  ┌───────────┐
│ muxDuplex │ │    │  │ muxDuplex │
│ Initiator │ │    │  │ Responder │
│ ChainSync │ │    │  │ BlockFetch│
└───────────┘ │    │  └───────────┘
              ▼    ▼
   ┌───────────┐  ┌───────────┐
   │ muxDuplex │  │ muxDuplex │
   │ Responder │  │ Initiator │
   │ ChainSync │  │ BlockFetch│
   └───────────┘  └───────────┘

demuxer :: ( MonadAsync m, MonadFork m, MonadMask m, MonadThrow ( STM m), MonadTimer m, MonadTime m) => [ MiniProtocolState mode m] -> MuxBearer m -> m void Source #

demux runs as a single separate thread and reads complete MuxSDU s from the underlying Mux Bearer and forwards it to the matching ingress queue.