Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split Network.Transport. THIS BREAKS THE CH BUILD.
Starting to prepare for release. Have not yet updated the CH build to reflect the changes.
- Loading branch information
ghc704
committed
Jul 6, 2012
1 parent
bfacdc4
commit 724dcf4
Showing
22 changed files
with
1,517 additions
and
80 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
Copyright Well-Typed LLP, 2011-2012 | ||
|
||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above | ||
copyright notice, this list of conditions and the following | ||
disclaimer in the documentation and/or other materials provided | ||
with the distribution. | ||
|
||
* Neither the name of the owner nor the names of other | ||
contributors may be used to endorse or promote products derived | ||
from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import Distribution.Simple | ||
main = defaultMain |
64 changes: 64 additions & 0 deletions
64
network-transport-inmemory/network-transport-inmemory.cabal
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
Name: network-transport-inmemory | ||
Version: 0.2.0 | ||
Cabal-Version: >=1.8 | ||
Build-Type: Simple | ||
License: BSD3 | ||
License-file: LICENSE | ||
Copyright: Well-Typed LLP | ||
Author: Duncan Coutts, Nicolas Wu, Edsko de Vries | ||
Maintainer: edsko@well-typed.com, dcoutts@well-typed.com | ||
Stability: experimental | ||
Homepage: http://github.com/haskell-distributed/distributed-process | ||
Bug-Reports: mailto:edsko@well-typed.com | ||
Synopsis: In-memory instantation of Network.Transport | ||
Description: In-memory instantation of Network.Transport | ||
Tested-With: GHC==7.0.4 GHC==7.2.2 GHC==7.4.1 GHC==7.4.2 | ||
Category: Network | ||
|
||
Library | ||
Build-Depends: base >= 4.3 && < 5, | ||
network-transport >= 0.2 && < 0.3, | ||
data-accessor >= 0.2 && < 0.3, | ||
bytestring >= 0.9 && < 0.10, | ||
containers >= 0.4 && < 0.5 | ||
Exposed-modules: Network.Transport.Chan | ||
ghc-options: -Wall -fno-warn-unused-do-bind | ||
HS-Source-Dirs: src | ||
|
||
Test-Suite TestMulticastInMemory | ||
Type: exitcode-stdio-1.0 | ||
Build-Depends: base >= 4.3 && < 5, | ||
network-transport >= 0.2 && < 0.3, | ||
data-accessor >= 0.2 && < 0.3, | ||
bytestring >= 0.9 && < 0.10, | ||
containers >= 0.4 && < 0.5, | ||
random >= 1.0 && < 1.1, | ||
ansi-terminal >= 0.5 && < 0.6 | ||
Main-Is: TestMulticastInMemory.hs | ||
ghc-options: -Wall -fno-warn-unused-do-bind | ||
Extensions: ExistentialQuantification, | ||
FlexibleInstances, | ||
DeriveDataTypeable, | ||
RankNTypes, | ||
OverloadedStrings | ||
HS-Source-Dirs: tests src | ||
|
||
Test-Suite TestInMemory | ||
Type: exitcode-stdio-1.0 | ||
Build-Depends: base >= 4.3 && < 5, | ||
network-transport >= 0.2 && < 0.3, | ||
data-accessor >= 0.2 && < 0.3, | ||
bytestring >= 0.9 && < 0.10, | ||
containers >= 0.4 && < 0.5, | ||
random >= 1.0 && < 1.1, | ||
ansi-terminal >= 0.5 && < 0.6, | ||
mtl >= 2.0 && < 2.2 | ||
Main-Is: TestInMemory.hs | ||
ghc-options: -Wall -fno-warn-unused-do-bind | ||
Extensions: ExistentialQuantification, | ||
FlexibleInstances, | ||
DeriveDataTypeable, | ||
RankNTypes, | ||
OverloadedStrings, | ||
OverlappingInstances | ||
HS-Source-Dirs: tests src |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
Copyright Well-Typed LLP, 2011-2012 | ||
|
||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above | ||
copyright notice, this list of conditions and the following | ||
disclaimer in the documentation and/or other materials provided | ||
with the distribution. | ||
|
||
* Neither the name of the owner nor the names of other | ||
contributors may be used to endorse or promote products derived | ||
from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import Distribution.Simple | ||
main = defaultMain |
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
Name: network-transport-tcp | ||
Version: 0.2.0 | ||
Cabal-Version: >=1.8 | ||
Build-Type: Simple | ||
License: BSD3 | ||
License-file: LICENSE | ||
Copyright: Well-Typed LLP | ||
Author: Duncan Coutts, Nicolas Wu, Edsko de Vries | ||
Maintainer: edsko@well-typed.com, dcoutts@well-typed.com | ||
Stability: experimental | ||
Homepage: http://github.com/haskell-distributed/distributed-process | ||
Bug-Reports: mailto:edsko@well-typed.com | ||
Synopsis: TCP instantation of Network.Transport | ||
Description: TCP instantation of Network.Transport | ||
Tested-With: GHC==7.0.4 GHC==7.2.2 GHC==7.4.1 GHC==7.4.2 | ||
Category: Network | ||
|
||
Library | ||
Build-Depends: base >= 4.3 && < 5, | ||
network-transport >= 0.2 && < 0.3, | ||
data-accessor >= 0.2 && < 0.3, | ||
containers >= 0.4 && < 0.5, | ||
bytestring >= 0.9 && < 0.10, | ||
network >= 2.3 && < 2.4 | ||
Exposed-modules: Network.Transport.TCP, | ||
Network.Transport.TCP.Internal | ||
ghc-options: -Wall -fno-warn-unused-do-bind | ||
HS-Source-Dirs: src | ||
|
||
Test-Suite TestTCP | ||
Type: exitcode-stdio-1.0 | ||
Main-Is: TestTCP.hs | ||
Build-Depends: base >= 4.3 && < 5, | ||
network-transport >= 0.2 && < 0.3, | ||
data-accessor >= 0.2 && < 0.3, | ||
containers >= 0.4 && < 0.5, | ||
bytestring >= 0.9 && < 0.10, | ||
network >= 2.3 && < 2.4, | ||
random >= 1.0 && < 1.1, | ||
ansi-terminal >= 0.5 && < 0.6, | ||
mtl >= 2.0 && < 2.2 | ||
ghc-options: -Wall -fno-warn-unused-do-bind -threaded -rtsopts -with-rtsopts=-N | ||
Extensions: ExistentialQuantification, | ||
FlexibleInstances, | ||
DeriveDataTypeable, | ||
RankNTypes, | ||
OverlappingInstances, | ||
OverloadedStrings | ||
HS-Source-Dirs: tests src |
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
2 changes: 1 addition & 1 deletion
2
...ort/src/Network/Transport/Internal/TCP.hs → ...tcp/src/Network/Transport/TCP/Internal.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
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 |
---|---|---|
@@ -0,0 +1,108 @@ | ||
{-# OPTIONS_GHC -fno-warn-orphans #-} | ||
module TestAuxiliary ( -- Running tests | ||
runTest | ||
, runTests | ||
-- Writing tests | ||
, forkTry | ||
, trySome | ||
, randomThreadDelay | ||
) where | ||
|
||
import Prelude hiding (catch) | ||
import Control.Concurrent (myThreadId, forkIO, ThreadId, throwTo, threadDelay) | ||
import Control.Concurrent.Chan (Chan) | ||
import Control.Monad (liftM2, unless) | ||
import Control.Exception (SomeException, try, catch) | ||
import System.Timeout (timeout) | ||
import System.IO (stdout, hFlush) | ||
import System.Console.ANSI ( SGR(SetColor, Reset) | ||
, Color(Red, Green) | ||
, ConsoleLayer(Foreground) | ||
, ColorIntensity(Vivid) | ||
, setSGR | ||
) | ||
import System.Random (randomIO) | ||
import Network.Transport | ||
import Traced (Traceable(..), traceShow) | ||
|
||
-- | Like fork, but throw exceptions in the child thread to the parent | ||
forkTry :: IO () -> IO ThreadId | ||
forkTry p = do | ||
tid <- myThreadId | ||
forkIO $ catch p (\e -> throwTo tid (e :: SomeException)) | ||
|
||
-- | Like try, but specialized to SomeException | ||
trySome :: IO a -> IO (Either SomeException a) | ||
trySome = try | ||
|
||
-- | Run the given test, catching timeouts and exceptions | ||
runTest :: String -> IO () -> IO Bool | ||
runTest description test = do | ||
putStr $ "Running " ++ show description ++ ": " | ||
hFlush stdout | ||
done <- try . timeout 60000000 $ test -- 60 seconds | ||
case done of | ||
Left err -> failed $ "(exception: " ++ show (err :: SomeException) ++ ")" | ||
Right Nothing -> failed $ "(timeout)" | ||
Right (Just ()) -> ok | ||
where | ||
failed :: String -> IO Bool | ||
failed err = do | ||
setSGR [SetColor Foreground Vivid Red] | ||
putStr "failed " | ||
setSGR [Reset] | ||
putStrLn err | ||
return False | ||
|
||
ok :: IO Bool | ||
ok = do | ||
setSGR [SetColor Foreground Vivid Green] | ||
putStrLn "ok" | ||
setSGR [Reset] | ||
return True | ||
|
||
-- | Run a bunch of tests and throw an exception if any fails | ||
runTests :: [(String, IO ())] -> IO () | ||
runTests tests = do | ||
success <- foldr (liftM2 (&&) . uncurry runTest) (return True) $ tests | ||
unless success $ fail "Some tests failed" | ||
|
||
-- | Random thread delay between 0 and the specified max | ||
randomThreadDelay :: Int -> IO () | ||
randomThreadDelay maxDelay = do | ||
delay <- randomIO :: IO Int | ||
threadDelay (delay `mod` maxDelay) | ||
|
||
-------------------------------------------------------------------------------- | ||
-- traceShow instances -- | ||
-------------------------------------------------------------------------------- | ||
|
||
instance Traceable EndPoint where | ||
trace = const Nothing | ||
|
||
instance Traceable Transport where | ||
trace = const Nothing | ||
|
||
instance Traceable Connection where | ||
trace = const Nothing | ||
|
||
instance Traceable Event where | ||
trace = traceShow | ||
|
||
instance Show err => Traceable (TransportError err) where | ||
trace = traceShow | ||
|
||
instance Traceable EndPointAddress where | ||
trace = traceShow . endPointAddressToByteString | ||
|
||
instance Traceable SomeException where | ||
trace = traceShow | ||
|
||
instance Traceable ThreadId where | ||
trace = const Nothing | ||
|
||
instance Traceable (Chan a) where | ||
trace = const Nothing | ||
|
||
instance Traceable Float where | ||
trace = traceShow |
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
Oops, something went wrong.