ouroboros-network-framework-0.1.0.0
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Network.Mux

Contents

Synopsis

Documentation

newtype OuroborosApplication (mode ∷ MuxMode) addr bytes m a b Source #

Like MuxApplication but using a MuxPeer rather than a raw Channel -> m a action.

Constructors

OuroborosApplication (ConnectionId addr → ControlMessageSTM m → [MiniProtocol mode bytes m a b]) 

type MuxProtocolBundle (mode ∷ MuxMode) addr bytes m a b = ConnectionId addr → ControlMessageSTM m → [MiniProtocol mode bytes m a b] Source #

data WithProtocolTemperature (pt ∷ ProtocolTemperature) a where Source #

We keep hot, warm and established application (or their context) distinct. It's only needed for a handly projectBundle map.

Instances

Instances details
Functor (WithProtocolTemperature pt) Source # 
Instance details

Defined in Ouroboros.Network.Mux

Applicative (WithProtocolTemperature 'Established) Source # 
Instance details

Defined in Ouroboros.Network.Mux

Applicative (WithProtocolTemperature 'Warm) Source # 
Instance details

Defined in Ouroboros.Network.Mux

Applicative (WithProtocolTemperature 'Hot) Source # 
Instance details

Defined in Ouroboros.Network.Mux

Foldable (WithProtocolTemperature pt) Source # 
Instance details

Defined in Ouroboros.Network.Mux

Methods

foldMonoid m ⇒ WithProtocolTemperature pt m → m Source #

foldMapMonoid m ⇒ (a → m) → WithProtocolTemperature pt a → m Source #

foldMap'Monoid m ⇒ (a → m) → WithProtocolTemperature pt a → m Source #

foldr ∷ (a → b → b) → b → WithProtocolTemperature pt a → b Source #

foldr' ∷ (a → b → b) → b → WithProtocolTemperature pt a → b Source #

foldl ∷ (b → a → b) → b → WithProtocolTemperature pt a → b Source #

foldl' ∷ (b → a → b) → b → WithProtocolTemperature pt a → b Source #

foldr1 ∷ (a → a → a) → WithProtocolTemperature pt a → a Source #

foldl1 ∷ (a → a → a) → WithProtocolTemperature pt a → a Source #

toListWithProtocolTemperature pt a → [a] Source #

nullWithProtocolTemperature pt a → Bool Source #

lengthWithProtocolTemperature pt a → Int Source #

elemEq a ⇒ a → WithProtocolTemperature pt a → Bool Source #

maximumOrd a ⇒ WithProtocolTemperature pt a → a Source #

minimumOrd a ⇒ WithProtocolTemperature pt a → a Source #

sumNum a ⇒ WithProtocolTemperature pt a → a Source #

productNum a ⇒ WithProtocolTemperature pt a → a Source #

Traversable (WithProtocolTemperature pt) Source # 
Instance details

Defined in Ouroboros.Network.Mux

Eq a ⇒ Eq (WithProtocolTemperature pt a) Source # 
Instance details

Defined in Ouroboros.Network.Mux

Show a ⇒ Show (WithProtocolTemperature pt a) Source # 
Instance details

Defined in Ouroboros.Network.Mux

Semigroup a ⇒ Semigroup (WithProtocolTemperature pt a) Source # 
Instance details

Defined in Ouroboros.Network.Mux

Monoid a ⇒ Monoid (WithProtocolTemperature 'Established a) Source # 
Instance details

Defined in Ouroboros.Network.Mux

Monoid a ⇒ Monoid (WithProtocolTemperature 'Warm a) Source # 
Instance details

Defined in Ouroboros.Network.Mux

Monoid a ⇒ Monoid (WithProtocolTemperature 'Hot a) Source # 
Instance details

Defined in Ouroboros.Network.Mux

data Bundle a Source #

A bundle of HotApp, WarmApp and EstablishedApp.

Constructors

Bundle 

Fields

Instances

Instances details
Functor Bundle Source # 
Instance details

Defined in Ouroboros.Network.Mux

Methods

fmap ∷ (a → b) → Bundle a → Bundle b Source #

(<$) ∷ a → Bundle b → Bundle a Source #

Applicative Bundle Source # 
Instance details

Defined in Ouroboros.Network.Mux

Methods

pure ∷ a → Bundle a Source #

(<*>)Bundle (a → b) → Bundle a → Bundle b Source #

liftA2 ∷ (a → b → c) → Bundle a → Bundle b → Bundle c Source #

(*>)Bundle a → Bundle b → Bundle b Source #

(<*)Bundle a → Bundle b → Bundle a Source #

Foldable Bundle Source # 
Instance details

Defined in Ouroboros.Network.Mux

Methods

foldMonoid m ⇒ Bundle m → m Source #

foldMapMonoid m ⇒ (a → m) → Bundle a → m Source #

foldMap'Monoid m ⇒ (a → m) → Bundle a → m Source #

foldr ∷ (a → b → b) → b → Bundle a → b Source #

foldr' ∷ (a → b → b) → b → Bundle a → b Source #

foldl ∷ (b → a → b) → b → Bundle a → b Source #

foldl' ∷ (b → a → b) → b → Bundle a → b Source #

foldr1 ∷ (a → a → a) → Bundle a → a Source #

foldl1 ∷ (a → a → a) → Bundle a → a Source #

toListBundle a → [a] Source #

nullBundle a → Bool Source #

lengthBundle a → Int Source #

elemEq a ⇒ a → Bundle a → Bool Source #

maximumOrd a ⇒ Bundle a → a Source #

minimumOrd a ⇒ Bundle a → a Source #

sumNum a ⇒ Bundle a → a Source #

productNum a ⇒ Bundle a → a Source #

Traversable Bundle Source # 
Instance details

Defined in Ouroboros.Network.Mux

Methods

traverseApplicative f ⇒ (a → f b) → Bundle a → f (Bundle b) Source #

sequenceAApplicative f ⇒ Bundle (f a) → f (Bundle a) Source #

mapMMonad m ⇒ (a → m b) → Bundle a → m (Bundle b) Source #

sequenceMonad m ⇒ Bundle (m a) → m (Bundle a) Source #

Eq a ⇒ Eq (Bundle a) Source # 
Instance details

Defined in Ouroboros.Network.Mux

Methods

(==)Bundle a → Bundle a → Bool Source #

(/=)Bundle a → Bundle a → Bool Source #

Show a ⇒ Show (Bundle a) Source # 
Instance details

Defined in Ouroboros.Network.Mux

Methods

showsPrecIntBundle a → ShowS Source #

showBundle a → String Source #

showList ∷ [Bundle a] → ShowS Source #

Semigroup a ⇒ Semigroup (Bundle a) Source # 
Instance details

Defined in Ouroboros.Network.Mux

Methods

(<>)Bundle a → Bundle a → Bundle a Source #

sconcatNonEmpty (Bundle a) → Bundle a Source #

stimesIntegral b ⇒ b → Bundle a → Bundle a Source #

Monoid a ⇒ Monoid (Bundle a) Source # 
Instance details

Defined in Ouroboros.Network.Mux

Methods

memptyBundle a Source #

mappendBundle a → Bundle a → Bundle a Source #

mconcat ∷ [Bundle a] → Bundle a Source #

type OuroborosBundle (mode ∷ MuxMode) addr bytes m a b = Bundle (MuxProtocolBundle mode addr bytes m a b) Source #

type MuxBundle (mode ∷ MuxMode) bytes m a b = Bundle [MiniProtocol mode bytes m a b] Source #

data MiniProtocol (mode ∷ MuxMode) bytes m a b Source #

newtype MiniProtocolNum Source #

The wire format includes the protocol numbers, and it's vital that these are stable. They are not necessarily dense however, as new ones are added and some old ones retired. So we use a dedicated class for this rather than reusing Enum. This also covers unrecognised protocol numbers on the decoding side.

Constructors

MiniProtocolNum Word16 

Instances

Instances details
Enum MiniProtocolNum 
Instance details

Defined in Network.Mux.Types

Eq MiniProtocolNum 
Instance details

Defined in Network.Mux.Types

Ord MiniProtocolNum 
Instance details

Defined in Network.Mux.Types

Show MiniProtocolNum 
Instance details

Defined in Network.Mux.Types

Ix MiniProtocolNum 
Instance details

Defined in Network.Mux.Types

data MiniProtocolLimits Source #

Per Miniprotocol limits

Constructors

MiniProtocolLimits 

Fields

  • maximumIngressQueue ∷ !Int

    Limit on the maximum number of bytes that can be queued in the miniprotocol's ingress queue.

data RunMiniProtocol (mode ∷ MuxMode) bytes m a b where Source #

data MuxPeer bytes m a where Source #

Constructors

MuxPeer ∷ ∀ (pr ∷ PeerRole) ps (st ∷ ps) failure bytes m a. (Show failure, ∀ (st' ∷ ps). Show (ClientHasAgency st'), ∀ (st' ∷ ps). Show (ServerHasAgency st'), ShowProxy ps) ⇒ Tracer m (TraceSendRecv ps) → Codec ps failure m bytes → Peer ps pr st m a → MuxPeer bytes m a 
MuxPeerPipelined ∷ ∀ (pr ∷ PeerRole) ps (st ∷ ps) failure bytes m a. (Show failure, ∀ (st' ∷ ps). Show (ClientHasAgency st'), ∀ (st' ∷ ps). Show (ServerHasAgency st'), ShowProxy ps) ⇒ Tracer m (TraceSendRecv ps) → Codec ps failure m bytes → PeerPipelined ps pr st m a → MuxPeer bytes m a 
MuxPeerRaw ∷ (Channel m bytes → m (a, Maybe bytes)) → MuxPeer bytes m a 

runMuxPeer ∷ (MonadCatch m, MonadAsync m) ⇒ MuxPeer bytes m a → Channel m bytes → m (a, Maybe bytes) Source #

Run a MuxPeer using either runPeer or runPipelinedPeer.

toApplication ∷ (MonadCatch m, MonadAsync m) ⇒ ConnectionId addr → ControlMessageSTM m → OuroborosApplication mode addr ByteString m a b → MuxApplication mode m a b Source #

mkMuxApplicationBundle ∷ ∀ mode addr bytes m a b. ConnectionId addr → Bundle (ControlMessageSTM m) → OuroborosBundle mode addr bytes m a b → MuxBundle mode bytes m a b Source #

mkMiniProtocolBundleMuxBundle mode bytes m a b → MiniProtocolBundle mode Source #

Make MiniProtocolBundle, which is used to create a mux interface with newMux. The output of mkMuxApplicationBundle can be used as input.

data ControlMessage Source #

Control signal sent to a mini-protocol. expected to exit, on Continue it should continue its operation

Constructors

Continue

Continue operation.

Quiesce

Hold on, e.g. do not sent messages until resumed. This is not used for any hot protocol.

Terminate

The client is expected to terminate as soon as possible.

type ControlMessageSTM m = STM m ControlMessage Source #

ControlMessageSTM should depend on muxMode (we only need to shedule stop for intiator side). This is not done only because this would break tests, but once the old api is removed it should be possible.

continueForeverApplicative (STM m) ⇒ proxy m → ControlMessageSTM m Source #

timeoutWithControlMessage ∷ MonadSTM m ⇒ ControlMessageSTM m → STM m a → m (Maybe a) Source #

First to finish synchronisation between Terminate state of ControlMessage and an stm action.

This should return STM m (Maybe a) but STM is a non-injective type family, and we would need to pass Proxy m to fix an ambiuous type (or use AllowAmbiguousTypes extension).

Re-exports

data MuxError Source #

Error type used in across the mux layer.

Constructors

MuxError 

Instances

Instances details
Show MuxError 
Instance details

Defined in Network.Mux.Trace

Generic MuxError 
Instance details

Defined in Network.Mux.Trace

Associated Types

type Rep MuxErrorTypeType Source #

Exception MuxError 
Instance details

Defined in Network.Mux.Trace

type Rep MuxError 
Instance details

Defined in Network.Mux.Trace

type Rep MuxError = D1 ('MetaData "MuxError" "Network.Mux.Trace" "network-mux-0.1.0.0-inplace" 'False) (C1 ('MetaCons "MuxError" 'PrefixI 'True) (S1 ('MetaSel ('Just "errorType") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 MuxErrorType) :*: S1 ('MetaSel ('Just "errorMsg") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 String)))

data MuxErrorType Source #

Enumeration of error conditions.

Constructors

MuxUnknownMiniProtocol

returned by decodeMuxSDUHeader, thrown by MuxBearer.

MuxDecodeError

return by decodeMuxSDUHeader, thrown by MuxBearer.

MuxBearerClosed

thrown by MuxBearer when received a null byte.

MuxIngressQueueOverRun

thrown by demux when violating maximumIngressQueue byte limit.

MuxInitiatorOnly

thrown when data arrives on a responder channel when the mux was set up as an InitiatorApp.

MuxIOException IOException

IOException thrown by

MuxSDUReadTimeout

thrown when reading of a single SDU takes too long

MuxSDUWriteTimeout

thrown when writing a single SDU takes too long

MuxShutdown !(Maybe MuxErrorType)

Result of runMiniProtocol's completionAction in case of an error or mux being closed while a mini-protocol was still running, this is not a clean exit.

MuxCleanShutdown

Mux stopped by stopMux

Instances

Instances details
Eq MuxErrorType 
Instance details

Defined in Network.Mux.Trace

Show MuxErrorType 
Instance details

Defined in Network.Mux.Trace