Skip to content

Commit

Permalink
adjust to deal with the latest network-transport-tcp API changes and …
Browse files Browse the repository at this point in the history
…refactor benchmarks and test runner accordingly
  • Loading branch information
hyperthunk committed Nov 11, 2018
1 parent 9a316db commit 391cb93
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 26 deletions.
11 changes: 6 additions & 5 deletions benchmarks/Channels.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Control.Monad
import Control.Applicative
import Control.Distributed.Process
import Control.Distributed.Process.Node
import Network.Transport.TCP (createTransport, defaultTCPParameters)
import Network.Transport.TCP (createTransport, defaultTCPAddr, defaultTCPParameters)
import Data.Binary (encode, decode)
import qualified Data.ByteString.Lazy as BSL

Expand Down Expand Up @@ -36,7 +36,8 @@ initialProcess "CLIENT" = do
main :: IO ()
main = do
[role, host, port] <- getArgs
Right transport <- createTransport
host port (\sn -> (host, port)) defaultTCPParameters
node <- newLocalNode transport initRemoteTable
runProcess node $ initialProcess role
trans <- createTransport (defaultTCPAddr host port) defaultTCPParameters
case trans of
Right transport -> do node <- newLocalNode transport initRemoteTable
runProcess node $ initialProcess role
Left other -> error $ show other
12 changes: 7 additions & 5 deletions benchmarks/Latency.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Control.Monad
import Control.Applicative
import Control.Distributed.Process
import Control.Distributed.Process.Node
import Network.Transport.TCP (createTransport, defaultTCPParameters)
import Network.Transport.TCP (createTransport, defaultTCPAddr, defaultTCPParameters)
import Data.Binary (encode, decode)
import qualified Data.ByteString.Lazy as BSL

Expand Down Expand Up @@ -31,7 +31,9 @@ initialProcess "CLIENT" = do
main :: IO ()
main = do
[role, host, port] <- getArgs
Right transport <- createTransport
host port (\sn -> (host, sn)) defaultTCPParameters
node <- newLocalNode transport initRemoteTable
runProcess node $ initialProcess role
trans <- createTransport
(defaultTCPAddr host port) defaultTCPParameters
case trans of
Right transport -> do node <- newLocalNode transport initRemoteTable
runProcess node $ initialProcess role
Left other -> error $ show other
4 changes: 2 additions & 2 deletions benchmarks/ProcessRing.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Control.Monad
import Control.Distributed.Process hiding (catch)
import Control.Distributed.Process.Node
import Control.Exception (catch, SomeException)
import Network.Transport.TCP (createTransport, defaultTCPParameters)
import Network.Transport.TCP (createTransport, defaultTCPAddr, defaultTCPParameters)
import System.Environment
import System.Console.GetOpt

Expand Down Expand Up @@ -111,7 +111,7 @@ main = do
(opt, _) <- parseArgv argv
putStrLn $ "options: " ++ (show opt)
Right transport <- createTransport
"127.0.0.1" "8090" (\sn -> ("127.0.0.1", sn)) defaultTCPParameters
(defaultTCPAddr "127.0.0.1" "8090" ) defaultTCPParameters
node <- newLocalNode transport initRemoteTable
catch (void $ runProcess node $ initialProcess opt)
(\(e :: SomeException) -> putStrLn $ "ERROR: " ++ (show e))
11 changes: 6 additions & 5 deletions benchmarks/Spawns.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Control.Monad
import Control.Applicative
import Control.Distributed.Process
import Control.Distributed.Process.Node
import Network.Transport.TCP (createTransport, defaultTCPParameters)
import Network.Transport.TCP (createTransport, defaultTCPAddr, defaultTCPParameters)
import Data.Binary (encode, decode)
import qualified Data.ByteString.Lazy as BSL

Expand Down Expand Up @@ -42,7 +42,8 @@ initialProcess "CLIENT" = do
main :: IO ()
main = do
[role, host, port] <- getArgs
Right transport <- createTransport
host port (\sn -> (host, sn)) defaultTCPParameters
node <- newLocalNode transport initRemoteTable
runProcess node $ initialProcess role
trans <- createTransport (defaultTCPAddr host port) defaultTCPParameters
case trans of
Right transport -> do node <- newLocalNode transport initRemoteTable
runProcess node $ initialProcess role
Left other -> error $ show other
11 changes: 6 additions & 5 deletions benchmarks/Throughput.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Control.Monad
import Control.Applicative
import Control.Distributed.Process
import Control.Distributed.Process.Node
import Network.Transport.TCP (createTransport, defaultTCPParameters)
import Network.Transport.TCP (createTransport, defaultTCPParameters, defaultTCPAddr)
import Data.Binary
import qualified Data.ByteString.Lazy as BSL
import Data.Typeable
Expand Down Expand Up @@ -67,7 +67,8 @@ initialProcess "CLIENT" = do
main :: IO ()
main = do
[role, host, port] <- getArgs
Right transport <- createTransport
host port (\sn -> (host, sn)) defaultTCPParameters
node <- newLocalNode transport initRemoteTable
runProcess node $ initialProcess role
trans <- createTransport (defaultTCPAddr host port) defaultTCPParameters
case trans of
Right transport -> do node <- newLocalNode transport initRemoteTable
runProcess node $ initialProcess role
Left other -> error $ show other
4 changes: 2 additions & 2 deletions distributed-process-tests/tests/runTCP.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Network.Transport.TCP
( createTransportExposeInternals
, TransportInternals(socketBetween)
, defaultTCPParameters
, defaultTCPAddr
, TCPParameters(..)
)
import Test.Framework (defaultMainWithArgs)
Expand All @@ -24,8 +25,7 @@ main = do
hSetBuffering stdout LineBuffering
hSetBuffering stderr LineBuffering
Right (transport, internals) <-
createTransportExposeInternals "127.0.0.1" "8080"
(\sn -> ("127.0.0.1", sn))
createTransportExposeInternals (defaultTCPAddr "127.0.0.1" "8080")
defaultTCPParameters { transportConnectTimeout = Just 3000000 }
ts <- tests TestTransport
{ testTransport = transport
Expand Down
10 changes: 8 additions & 2 deletions stack-ghc-8.0.2.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
resolver: lts-9.0
resolver: lts-9.21

# added -location for network-transport-tcp-0.6.0
# since c7fd79 broke the client facing API for createTransport :/

packages:
- '.'
- distributed-process-tests/
- location:
git: https://github.com/haskell-distributed/network-transport-tcp.git
commit: d87d6f55697a94a1fbf211ff9c1bb769a1e129cd
extra-dep: true

extra-deps:
- rank1dynamic-0.4.0
- distributed-static-0.3.8
- network-transport-0.5.2
- network-transport-tcp-0.6.0
- network-transport-inmemory-0.5.2
- rematch-0.2.0.0

Expand Down

0 comments on commit 391cb93

Please sign in to comment.