Safe Haskell | None |
---|---|
Language | Haskell2010 |
Ouroboros.Network.Mux
Contents
Synopsis
- data MuxMode where
- newtype OuroborosApplication (mode :: MuxMode ) addr bytes m a b = 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]
-
data
ProtocolTemperature
- = Established
- | Warm
- | Hot
- data TokProtocolTemperature (pt :: ProtocolTemperature ) where
- data SomeTokProtocolTemperature where
-
data
WithProtocolTemperature
(pt ::
ProtocolTemperature
) a
where
- WithHot :: !a -> WithProtocolTemperature Hot a
- WithWarm :: !a -> WithProtocolTemperature Warm a
- WithEstablished :: !a -> WithProtocolTemperature Established a
- withoutProtocolTemperature :: WithProtocolTemperature pt a -> a
- data WithSomeProtocolTemperature a where
- withoutSomeProtocolTemperature :: WithSomeProtocolTemperature a -> a
-
data
Bundle
a =
Bundle
{
- withHot :: !( WithProtocolTemperature Hot a)
- withWarm :: !( WithProtocolTemperature Warm a)
- withEstablished :: !( WithProtocolTemperature Established a)
- projectBundle :: TokProtocolTemperature pt -> Bundle a -> a
- type OuroborosBundle (mode :: MuxMode ) addr bytes m a b = Bundle ( MuxProtocolBundle mode addr bytes m a b)
- type MuxBundle (mode :: MuxMode ) bytes m a b = Bundle [ MiniProtocol mode bytes m a b]
-
data
MiniProtocol
(mode ::
MuxMode
) bytes m a b =
MiniProtocol
{
- miniProtocolNum :: ! MiniProtocolNum
- miniProtocolLimits :: ! MiniProtocolLimits
- miniProtocolRun :: !( RunMiniProtocol mode bytes m a b)
- newtype MiniProtocolNum = MiniProtocolNum Word16
-
data
MiniProtocolLimits
=
MiniProtocolLimits
{
- maximumIngressQueue :: ! Int
-
data
RunMiniProtocol
(mode ::
MuxMode
) bytes m a b
where
- InitiatorProtocolOnly :: MuxPeer bytes m a -> RunMiniProtocol InitiatorMode bytes m a Void
- ResponderProtocolOnly :: MuxPeer bytes m b -> RunMiniProtocol ResponderMode bytes m Void b
- InitiatorAndResponderProtocol :: MuxPeer bytes m a -> MuxPeer bytes m b -> RunMiniProtocol InitiatorResponderMode bytes m a b
-
data
MuxPeer
bytes m a
where
- MuxPeer :: forall (pr :: PeerRole ) ps (st :: ps) failure bytes m a. ( Show failure, forall (st' :: ps). Show ( ClientHasAgency st'), forall (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 :: forall (pr :: PeerRole ) ps (st :: ps) failure bytes m a. ( Show failure, forall (st' :: ps). Show ( ClientHasAgency st'), forall (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)
- toApplication :: ( MonadCatch m, MonadAsync m) => ConnectionId addr -> ControlMessageSTM m -> OuroborosApplication mode addr ByteString m a b -> MuxApplication mode m a b
- mkMuxApplicationBundle :: forall mode addr bytes m a b. ConnectionId addr -> Bundle ( ControlMessageSTM m) -> OuroborosBundle mode addr bytes m a b -> MuxBundle mode bytes m a b
- mkMiniProtocolBundle :: MuxBundle mode bytes m a b -> MiniProtocolBundle mode
- data ControlMessage
- type ControlMessageSTM m = STM m ControlMessage
- continueForever :: Applicative ( STM m) => proxy m -> ControlMessageSTM m
- timeoutWithControlMessage :: MonadSTM m => ControlMessageSTM m -> STM m a -> m ( Maybe a)
-
data
MuxError
=
MuxError
{
- errorType :: ! MuxErrorType
- errorMsg :: ! String
- data MuxErrorType
- type family HasInitiator (mode :: MuxMode ) :: Bool where ...
- type family HasResponder (mode :: MuxMode ) :: Bool where ...
Documentation
Constructors
InitiatorMode :: MuxMode | |
ResponderMode :: MuxMode | |
InitiatorResponderMode :: MuxMode |
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 ProtocolTemperature Source #
There are three kinds of applications: warm, hot and established (ones that run in for both warm and hot peers).
Constructors
Established | |
Warm | |
Hot |
Instances
Eq ProtocolTemperature Source # | |
Defined in Ouroboros.Network.Mux Methods (==) :: ProtocolTemperature -> ProtocolTemperature -> Bool Source # (/=) :: ProtocolTemperature -> ProtocolTemperature -> Bool Source # |
|
Ord ProtocolTemperature Source # | |
Defined in Ouroboros.Network.Mux Methods compare :: ProtocolTemperature -> ProtocolTemperature -> Ordering Source # (<) :: ProtocolTemperature -> ProtocolTemperature -> Bool Source # (<=) :: ProtocolTemperature -> ProtocolTemperature -> Bool Source # (>) :: ProtocolTemperature -> ProtocolTemperature -> Bool Source # (>=) :: ProtocolTemperature -> ProtocolTemperature -> Bool Source # max :: ProtocolTemperature -> ProtocolTemperature -> ProtocolTemperature Source # min :: ProtocolTemperature -> ProtocolTemperature -> ProtocolTemperature Source # |
|
Show ProtocolTemperature Source # | |
Defined in Ouroboros.Network.Mux |
data TokProtocolTemperature (pt :: ProtocolTemperature ) where Source #
Singletons for
AppKind
Constructors
TokHot :: TokProtocolTemperature Hot | |
TokWarm :: TokProtocolTemperature Warm | |
TokEstablished :: TokProtocolTemperature Established |
data SomeTokProtocolTemperature where Source #
Constructors
SomeTokProtocolTemperature :: TokProtocolTemperature pt -> SomeTokProtocolTemperature |
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.
Constructors
WithHot :: !a -> WithProtocolTemperature Hot a | |
WithWarm :: !a -> WithProtocolTemperature Warm a | |
WithEstablished :: !a -> WithProtocolTemperature Established a |
Instances
withoutProtocolTemperature :: WithProtocolTemperature pt a -> a Source #
data WithSomeProtocolTemperature a where Source #
Constructors
WithSomeProtocolTemperature :: WithProtocolTemperature pt a -> WithSomeProtocolTemperature a |
Instances
Functor WithSomeProtocolTemperature Source # | |
Defined in Ouroboros.Network.Mux Methods fmap :: (a -> b) -> WithSomeProtocolTemperature a -> WithSomeProtocolTemperature b Source # (<$) :: a -> WithSomeProtocolTemperature b -> WithSomeProtocolTemperature a Source # |
|
Show a => Show ( WithSomeProtocolTemperature a) Source # | |
Defined in Ouroboros.Network.Mux |
A bundle of
HotApp
,
WarmApp
and
EstablishedApp
.
Constructors
Bundle | |
Fields
|
Instances
projectBundle :: TokProtocolTemperature pt -> Bundle a -> a Source #
type OuroborosBundle (mode :: MuxMode ) addr bytes m a b = Bundle ( MuxProtocolBundle mode addr bytes m a b) Source #
data MiniProtocol (mode :: MuxMode ) bytes m a b Source #
Constructors
MiniProtocol | |
Fields
|
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
data MiniProtocolLimits Source #
Per Miniprotocol limits
Constructors
MiniProtocolLimits | |
Fields
|
data RunMiniProtocol (mode :: MuxMode ) bytes m a b where Source #
Constructors
InitiatorProtocolOnly :: MuxPeer bytes m a -> RunMiniProtocol InitiatorMode bytes m a Void | |
ResponderProtocolOnly :: MuxPeer bytes m b -> RunMiniProtocol ResponderMode bytes m Void b | |
InitiatorAndResponderProtocol :: MuxPeer bytes m a -> MuxPeer bytes m b -> RunMiniProtocol InitiatorResponderMode bytes m a b |
data MuxPeer bytes m a where Source #
Constructors
MuxPeer :: forall (pr :: PeerRole ) ps (st :: ps) failure bytes m a. ( Show failure, forall (st' :: ps). Show ( ClientHasAgency st'), forall (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 :: forall (pr :: PeerRole ) ps (st :: ps) failure bytes m a. ( Show failure, forall (st' :: ps). Show ( ClientHasAgency st'), forall (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
using either
MuxPeer
or
runPeer
.
runPipelinedPeer
toApplication :: ( MonadCatch m, MonadAsync m) => ConnectionId addr -> ControlMessageSTM m -> OuroborosApplication mode addr ByteString m a b -> MuxApplication mode m a b Source #
mkMuxApplicationBundle :: forall 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 #
mkMiniProtocolBundle :: MuxBundle 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. |
Instances
Eq ControlMessage Source # | |
Defined in Ouroboros.Network.Mux Methods (==) :: ControlMessage -> ControlMessage -> Bool Source # (/=) :: ControlMessage -> ControlMessage -> Bool Source # |
|
Show ControlMessage Source # | |
Defined in Ouroboros.Network.Mux |
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.
continueForever :: Applicative ( 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
from Network.Mux
Error type used in across the mux layer.
Constructors
MuxError | |
Fields
|
Instances
Show MuxError | |
Generic MuxError | |
Exception MuxError | |
Defined in Network.Mux.Trace Methods toException :: MuxError -> SomeException Source # fromException :: SomeException -> Maybe MuxError Source # displayException :: MuxError -> String Source # |
|
type Rep MuxError | |
Defined in Network.Mux.Trace
type
Rep
MuxError
=
D1
('
MetaData
"MuxError" "Network.Mux.Trace" "network-mux-0.1.0.1-7ZKx91o48G8EWFMuCmTsQc" '
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
|
MuxDecodeError |
return by
|
MuxBearerClosed |
thrown by
|
MuxIngressQueueOverRun |
thrown by
|
MuxInitiatorOnly |
thrown when data arrives on a responder channel when the
mux was set up as an
|
MuxIOException IOException |
|
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
|
Instances
Eq MuxErrorType | |
Defined in Network.Mux.Trace Methods (==) :: MuxErrorType -> MuxErrorType -> Bool Source # (/=) :: MuxErrorType -> MuxErrorType -> Bool Source # |
|
Show MuxErrorType | |
Defined in Network.Mux.Trace |
type family HasInitiator (mode :: MuxMode ) :: Bool where ... Source #
Equations
HasInitiator ' InitiatorMode = ' True | |
HasInitiator ' ResponderMode = ' False | |
HasInitiator ' InitiatorResponderMode = ' True |
type family HasResponder (mode :: MuxMode ) :: Bool where ... Source #
Equations
HasResponder ' InitiatorMode = ' False | |
HasResponder ' ResponderMode = ' True | |
HasResponder ' InitiatorResponderMode = ' True |