-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4693 from karknu/karknu/keepalive_start
KeepAlive Client collect samples on first packet
- Loading branch information
Showing
6 changed files
with
72 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 18 additions & 9 deletions
27
ouroboros-network-protocols/testlib/Ouroboros/Network/Protocol/KeepAlive/Direct.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,28 @@ | ||
{-# LANGUAGE NamedFieldPuns #-} | ||
{-# LANGUAGE RankNTypes #-} | ||
|
||
module Ouroboros.Network.Protocol.KeepAlive.Direct where | ||
|
||
import Ouroboros.Network.Protocol.KeepAlive.Client | ||
import Ouroboros.Network.Protocol.KeepAlive.Server | ||
|
||
direct :: Monad m | ||
|
||
direct :: forall a b m. Monad m | ||
=> KeepAliveServer m a | ||
-> KeepAliveClient m b | ||
-> m (a, b) | ||
direct KeepAliveServer { recvMsgDone } | ||
(SendMsgDone mdone) = | ||
(,) <$> recvMsgDone <*> mdone | ||
direct KeepAliveServer { recvMsgKeepAlive } | ||
(SendMsgKeepAlive _cookie mclient) = do | ||
server <- recvMsgKeepAlive | ||
client <- mclient | ||
direct server client | ||
direct srv (KeepAliveClient clientM) = do | ||
go srv =<< clientM | ||
where | ||
go :: Monad m | ||
=> KeepAliveServer m a | ||
-> KeepAliveClientSt m b | ||
-> m (a, b) | ||
go KeepAliveServer { recvMsgDone } | ||
(SendMsgDone mdone) = | ||
(,) <$> recvMsgDone <*> mdone | ||
go KeepAliveServer { recvMsgKeepAlive } | ||
(SendMsgKeepAlive _cookie mclient) = do | ||
server <- recvMsgKeepAlive | ||
client <- mclient | ||
go server client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters