ouroboros-network-framework
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Network.Channel

Synopsis

Documentation

data Channel (m :: Type -> Type) a #

A channel which can send and receive values.

It is more general than what `network-mux` requires, see ByteChannel instead. However this is useful for testing purposes when one is either using mux or connecting two ends directly.

Constructors

Channel 

Fields

  • send :: a -> m ()

    Write bytes to the channel.

    It maybe raise exceptions.

  • recv :: m (Maybe a)

    Read some input from the channel, or Nothing to indicate EOF.

    Note that having received EOF it is still possible to send. The EOF condition is however monotonic.

    It may raise exceptions (as appropriate for the monad and kind of channel).

fixedInputChannel :: MonadSTM m => [a] -> m (Channel m a) Source #

A Channel with a fixed input, and where all output is discarded.

The input is guaranteed to be supplied via read with the given chunk boundaries.

This is only useful for testing. In particular the fixed chunk boundaries can be used to test that framing and other codecs work with any possible chunking.

createConnectedBufferedChannelsUnbounded :: MonadSTM m => m (Channel m a, Channel m a) Source #

Create a pair of channels that are connected via two unbounded buffers.

This is primarily useful for testing protocols.

createConnectedBufferedChannels :: MonadLabelledSTM m => Natural -> m (Channel m a, Channel m a) Source #

Create a pair of channels that are connected via N-place buffers.

This variant blocks when send would exceed the maximum buffer size. Use this variant when you want the environment rather than the Peer to limit the pipelining.

This is primarily useful for testing protocols.

createConnectedBufferedChannelsSTM :: forall (m :: Type -> Type) a. MonadLabelledSTM m => Natural -> STM m (Channel (STM m) a, Channel (STM m) a) Source #

As createConnectedBufferedChannels, but in STM.

TODO: it should return a pair of `Channel m a`.

createPipelineTestChannels :: MonadSTM m => Natural -> m (Channel m a, Channel m a) Source #

Create a pair of channels that are connected via N-place buffers.

This variant fails when send would exceed the maximum buffer size. Use this variant when you want the PeerPipelined to limit the pipelining itself, and you want to check that it does not exceed the expected level of pipelining.

This is primarily useful for testing protocols.