| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
Hydra.Network
Contents
Description
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 ()
- data StallReason
- data Host = Host {
- hostname :: Text
- port :: PortNumber
- newtype ProtocolVersion = ProtocolVersion Natural
- newtype NodeId = NodeId {
- nodeId :: Text
- data WhichEtcd
- data NetworkCallback msg m = NetworkCallback {
- deliver :: msg -> m ()
- onConnectivity :: Connectivity -> m ()
- type NetworkComponent m inbound outbound a = NetworkCallback inbound m -> (Network m outbound -> m a) -> m a
- data Connectivity
- = PeerConnected { }
- | PeerDisconnected { }
- | NetworkConnected
- | NetworkDisconnected
- | VersionMismatch { }
- | ClusterIDMismatch {
- clusterPeers :: Text
- | BroadcastStalled { }
- | BroadcastResumed
- data NetworkConfiguration = NetworkConfiguration {
- persistenceDir :: FilePath
- signingKey :: Secret (SigningKey HydraKey)
- otherParties :: [Party]
- listen :: Host
- advertise :: Host
- peers :: [Host]
- nodeId :: NodeId
- whichEtcd :: WhichEtcd
- readHost :: MonadFail m => String -> m Host
- showHost :: Host -> String
- readPort :: MonadFail m => String -> m PortNumber
- data IP
- data PortNumber
Documentation
data StallReason Source #
Why the node's outbound broadcast hand-off is reporting itself stalled.
The two conditions are not interchangeable, and conflating them misreports
a healthy network: NoProgress means nothing is getting through at all,
while BacklogFull also fires on a producer outrunning a consumer that is
still delivering, just not fast enough. Anything telling a client or an
operator about a stall should say which one it saw rather than blaming
reachability.
Constructors
| NoProgress | Nothing has completed for longer than the allowed period, so the network cannot currently be reached. |
| BacklogFull | The hand-off holds more than it would drain within the allowed period at its recent rate, or its maximum. A fast client can cause this against a network that is still delivering. |
Instances
Constructors
| Host | |
Fields
| |
Instances
newtype ProtocolVersion Source #
Constructors
| ProtocolVersion Natural |
Instances
Instances
| FromJSON NodeId Source # | |
Defined in Hydra.Network | |
| ToJSON NodeId Source # | |
Defined in Hydra.Network Methods toEncoding :: NodeId -> Encoding toJSONList :: [NodeId] -> Value toEncodingList :: [NodeId] -> Encoding | |
| IsString NodeId Source # | |
Defined in Hydra.Network Methods fromString :: String -> NodeId Source # | |
| Generic NodeId Source # | |
| Read NodeId Source # | |
| Show NodeId Source # | |
| FromCBOR NodeId Source # | |
| ToCBOR NodeId Source # | |
Defined in Hydra.Network Methods 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 # | |
| type Rep NodeId Source # | |
Defined in Hydra.Network | |
Constructors
| EmbeddedEtcd | |
| SystemEtcd |
Instances
| FromJSON WhichEtcd Source # | |
Defined in Hydra.Network | |
| ToJSON WhichEtcd Source # | |
Defined in Hydra.Network Methods toEncoding :: WhichEtcd -> Encoding toJSONList :: [WhichEtcd] -> Value toEncodingList :: [WhichEtcd] -> Encoding | |
| Generic WhichEtcd Source # | |
| Show WhichEtcd Source # | |
| FromCBOR WhichEtcd Source # | |
| ToCBOR WhichEtcd Source # | |
Defined in Hydra.Network Methods toCBOR :: WhichEtcd -> Encoding encodedSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy WhichEtcd -> Size encodedListSizeExpr :: (forall t. ToCBOR t => Proxy t -> Size) -> Proxy [WhichEtcd] -> Size | |
| Eq WhichEtcd Source # | |
| type Rep WhichEtcd Source # | |
data 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.
Constructors
| NetworkCallback | |
Fields
| |
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.
data Connectivity Source #
Constructors
| PeerConnected | Individual peer appeared alive on network. |
| PeerDisconnected | Individual peer disappeared from network (has not been seen active in a while). |
| NetworkConnected | Connected to Hydra network. |
| NetworkDisconnected | Disconnected from Hydra network. |
| VersionMismatch | |
Fields | |
| ClusterIDMismatch | |
Fields
| |
| BroadcastStalled | Outbound messages have backed up and are not being handed to the
cluster. They go out once they can, but are held in memory until then,
so stopping the node while stalled discards whatever it had not handed
over (traced as |
Fields | |
| BroadcastResumed | The outbound queue started draining again. |
Instances
data NetworkConfiguration Source #
Configuration for a Node network layer.
Constructors
| NetworkConfiguration | |
Fields
| |
Instances
| FromJSON IP | |
Defined in Hydra.Network | |
| ToJSON IP | |
Defined in Hydra.Network | |
| Data IP | |
Defined in Data.IP.Addr Methods 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 Methods 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.15-4kPUavENdBJ2rq2e05hOkX" '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))) | |
data PortNumber #
Instances
Orphan instances
| FromJSON IP Source # | |
| FromJSON PortNumber Source # | |
| ToJSON IP Source # | |
| ToJSON PortNumber Source # | |
Methods toJSON :: PortNumber -> Value toEncoding :: PortNumber -> Encoding toJSONList :: [PortNumber] -> Value toEncodingList :: [PortNumber] -> Encoding omitField :: PortNumber -> Bool | |