Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Asynchronous messaging interface to the Hydra Network, e.g to other Hydra nodes.
Concrete implementations are provided by submodules. Import those instead of this one if interested in actually configuring and running a real network layer.
Incoming and outgoing messages are modelled as Message
data type.
Synopsis
- newtype Network m msg = Network {
- broadcast :: msg -> m ()
- newtype NetworkCallback msg m = NetworkCallback {
- deliver :: msg -> m ()
- type NetworkComponent m inbound outbound a = NetworkCallback inbound m -> (Network m outbound -> m a) -> m a
- data IP
- data Host = Host {
- hostname :: Text
- port :: PortNumber
- newtype NodeId = NodeId {}
- showHost :: Host -> String
- readHost :: MonadFail m => String -> m Host
- data PortNumber
- readPort :: MonadFail m => String -> m PortNumber
- close :: Socket -> IO ()
Types
newtype Network m msg Source #
Interface from the application to the network layer.
newtype NetworkCallback msg m Source #
Interface from network layer to the application. XXX: Reliably delivering a message in the crash-recovery fault model is tricky. According to "Introduction to Reliable and Secure Distributed Programming" section "2.2.4 Crashes with recoveries" explains that storing to stable storage and just pointing to stored events is a better way.
NetworkCallback | |
|
type NetworkComponent m inbound outbound a = NetworkCallback inbound m -> (Network m outbound -> m a) -> m a Source #
A type tying both inbound and outbound messages sending in a single Component.
A NetworkComponent
can have different inbound and outbound message types.
Instances
Arbitrary IP | |
FromJSON IP | |
Defined in Hydra.Network | |
ToJSON IP | |
Defined in Hydra.Network | |
Data IP | |
Defined in Data.IP.Addr gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> IP -> c IP Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c IP Source # toConstr :: IP -> Constr Source # dataTypeOf :: IP -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c IP) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c IP) Source # gmapT :: (forall b. Data b => b -> b) -> IP -> IP Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> IP -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> IP -> r Source # gmapQ :: (forall d. Data d => d -> u) -> IP -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> IP -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> IP -> m IP Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> IP -> m IP Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> IP -> m IP Source # | |
IsString IP | |
Defined in Data.IP.Addr fromString :: String -> IP Source # | |
Enum IP | |
Generic IP | |
Read IP | |
Show IP | |
Eq IP | |
Ord IP | |
type Rep IP | |
Defined in Data.IP.Addr type Rep IP = D1 ('MetaData "IP" "Data.IP.Addr" "iproute-1.7.14-AW32e5ky9bG9WbzuVXEuBX" 'False) (C1 ('MetaCons "IPv4" 'PrefixI 'True) (S1 ('MetaSel ('Just "ipv4") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedUnpack) (Rec0 IPv4)) :+: C1 ('MetaCons "IPv6" 'PrefixI 'True) (S1 ('MetaSel ('Just "ipv6") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 IPv6))) |
Host | |
|
Instances
Arbitrary Host Source # | |
FromJSON Host Source # | |
Defined in Hydra.Network | |
ToJSON Host Source # | |
Defined in Hydra.Network | |
Generic Host Source # | |
Read Host Source # | |
Show Host Source # | |
FromCBOR Host Source # | |
ToCBOR Host Source # | |
Defined in Hydra.Network encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy Host -> Size encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy [Host] -> Size | |
Eq Host Source # | |
Ord Host Source # | |
type Rep Host Source # | |
Defined in Hydra.Network type Rep Host = D1 ('MetaData "Host" "Hydra.Network" "hydra-node-0.20.0-5pXAEiXeWsXH8K4KfwlMxW" 'False) (C1 ('MetaCons "Host" 'PrefixI 'True) (S1 ('MetaSel ('Just "hostname") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "port") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PortNumber))) |
Instances
Arbitrary NodeId Source # | |
FromJSON NodeId Source # | |
Defined in Hydra.Network parseJSON :: Value -> Parser NodeId parseJSONList :: Value -> Parser [NodeId] | |
ToJSON NodeId Source # | |
Defined in Hydra.Network toEncoding :: NodeId -> Encoding toJSONList :: [NodeId] -> Value toEncodingList :: [NodeId] -> Encoding | |
IsString NodeId Source # | |
Defined in Hydra.Network fromString :: String -> NodeId Source # | |
Read NodeId Source # | |
Show NodeId Source # | |
FromCBOR NodeId Source # | |
ToCBOR NodeId Source # | |
Defined in Hydra.Network encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy NodeId -> Size encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy [NodeId] -> Size | |
Eq NodeId Source # | |
Ord NodeId Source # | |
Defined in Hydra.Network |
data PortNumber #
Instances
Utility functions
Orphan instances
Arbitrary PortNumber Source # | |
arbitrary :: Gen PortNumber shrink :: PortNumber -> [PortNumber] | |
FromJSON IP Source # | |
FromJSON PortNumber Source # | |
parseJSON :: Value -> Parser PortNumber parseJSONList :: Value -> Parser [PortNumber] | |
ToJSON IP Source # | |
ToJSON PortNumber Source # | |
toJSON :: PortNumber -> Value toEncoding :: PortNumber -> Encoding toJSONList :: [PortNumber] -> Value toEncodingList :: [PortNumber] -> Encoding omitField :: PortNumber -> Bool | |
FromCBOR PortNumber Source # | |
fromCBOR :: Decoder s PortNumber label :: Proxy PortNumber -> Text | |
ToCBOR PortNumber Source # | |
toCBOR :: PortNumber -> Encoding encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy PortNumber -> Size encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy [PortNumber] -> Size |