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])
- 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 {}
- 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
- toApplication :: (MonadCatch m, MonadAsync m) => ConnectionId addr -> ControlMessageSTM m -> OuroborosApplication mode addr ByteString m a b -> MuxApplication mode m a b
- 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]) |
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 |
toApplication :: (MonadCatch m, MonadAsync m) => ConnectionId addr -> ControlMessageSTM m -> OuroborosApplication mode addr ByteString m a b -> MuxApplication mode m a b Source #
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 # (/=) :: ControlMessage -> ControlMessage -> Bool # | |
Show ControlMessage Source # | |
Defined in Ouroboros.Network.Mux Methods showsPrec :: Int -> ControlMessage -> ShowS # show :: ControlMessage -> String # showList :: [ControlMessage] -> ShowS # |
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 accross the mux layer.
Constructors
MuxError | |
Fields
|
Instances
Show MuxError | |
Generic MuxError | |
Exception MuxError | |
Defined in Network.Mux.Trace Methods toException :: MuxError -> SomeException # fromException :: SomeException -> Maybe MuxError # displayException :: MuxError -> String # | |
type Rep MuxError | |
Defined in Network.Mux.Trace type Rep MuxError = D1 ('MetaData "MuxError" "Network.Mux.Trace" "network-mux-0.1.0.0-9lGOxxFsgpyBkmgq5iX8kU" '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. |
MuxCleanShutdown | Mux stopped by |
MuxBlockedOnCompletionVar !MiniProtocolNum | Mux blocked on |
Instances
Eq MuxErrorType | |
Defined in Network.Mux.Trace | |
Show MuxErrorType | |
Defined in Network.Mux.Trace Methods showsPrec :: Int -> MuxErrorType -> ShowS # show :: MuxErrorType -> String # showList :: [MuxErrorType] -> ShowS # |
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 |