hargettp / courier Goto Github PK
View Code? Open in Web Editor NEWA message-passing library, intended for simplifying network applications
License: MIT License
A message-passing library, intended for simplifying network applications
License: MIT License
Full log:
Building courier-0.1.1.5...
Preprocessing library courier-0.1.1.5...
[1 of 9] Compiling Control.Concurrent.Mailbox ( src/Control/Concurrent/Mailbox.hs, dist/build/Control/Concurrent/Mailbox.o )
[2 of 9] Compiling Network.Endpoints ( src/Network/Endpoints.hs, dist/build/Network/Endpoints.o )
[3 of 9] Compiling Network.RPC ( src/Network/RPC.hs, dist/build/Network/RPC.o )
[4 of 9] Compiling Network.RPC.Typed ( src/Network/RPC/Typed.hs, dist/build/Network/RPC/Typed.o )
[5 of 9] Compiling Network.Transport ( src/Network/Transport.hs, dist/build/Network/Transport.o )
[6 of 9] Compiling Network.Transport.Sockets ( src/Network/Transport/Sockets.hs, dist/build/Network/Transport/Sockets.o )
[7 of 9] Compiling Network.Transport.Sockets.TCP ( src/Network/Transport/Sockets/TCP.hs, dist/build/Network/Transport/Sockets/TCP.o )
[8 of 9] Compiling Network.Transport.Memory ( src/Network/Transport/Memory.hs, dist/build/Network/Transport/Memory.o )
[9 of 9] Compiling Network.Transport.Sockets.UDP ( src/Network/Transport/Sockets/UDP.hs, dist/build/Network/Transport/Sockets/UDP.o )
src/Network/Transport/Sockets/UDP.hs:92:3: warning: [-Wdeprecations]
In the use of ‘bindSocket’ (imported from Network.Socket):
Deprecated: "use 'bind'"
Preprocessing executable 'echo-server' for courier-0.1.1.5...
[1 of 1] Compiling Main ( echo/EchoServer.hs, dist/build/echo-server/echo-server-tmp/Main.o )
Linking dist/build/echo-server/echo-server ...
Preprocessing executable 'echo-client' for courier-0.1.1.5...
[1 of 1] Compiling Main ( echo/EchoClient.hs, dist/build/echo-client/echo-client-tmp/Main.o )
Linking dist/build/echo-client/echo-client ...
Preprocessing test suite 'test-courier' for courier-0.1.1.5...
[1 of 9] Compiling TestUtils ( tests/TestUtils.hs, dist/build/test-courier/test-courier-tmp/TestUtils.o )
tests/TestUtils.hs:94:8: warning: [-Wdeprecations]
In the use of ‘bindSocket’ (imported from Network.Socket):
Deprecated: "use 'bind'"
[2 of 9] Compiling TransportTestSuite ( tests/TransportTestSuite.hs, dist/build/test-courier/test-courier-tmp/TransportTestSuite.o )
[3 of 9] Compiling TestUDP ( tests/TestUDP.hs, dist/build/test-courier/test-courier-tmp/TestUDP.o )
[4 of 9] Compiling TestTCP ( tests/TestTCP.hs, dist/build/test-courier/test-courier-tmp/TestTCP.o )
[5 of 9] Compiling TestRPCTyped ( tests/TestRPCTyped.hs, dist/build/test-courier/test-courier-tmp/TestRPCTyped.o )
[6 of 9] Compiling TestRPC ( tests/TestRPC.hs, dist/build/test-courier/test-courier-tmp/TestRPC.o )
[7 of 9] Compiling TestMemory ( tests/TestMemory.hs, dist/build/test-courier/test-courier-tmp/TestMemory.o )
[8 of 9] Compiling TestMailbox ( tests/TestMailbox.hs, dist/build/test-courier/test-courier-tmp/TestMailbox.o )
[9 of 9] Compiling Main ( tests/Tests.hs, dist/build/test-courier/test-courier-tmp/Main.o )
Linking dist/build/test-courier/test-courier ...
mbox-creation: [OK]
mbox-simple-write: [OK]
mbox-write-read: [OK]
mbox-match: [OK]
mbox-find: [OK]
mem-sendReceive: [OK]
mem-send2Receive2: [OK]
mem-sendReceive-2-serial-servers: [OK]
mem-sendReceive-2-serial-clients: [OK]
mem-withClient-withServer: [OK]
mem-rpc-one-hear-call: [OK]
mem-rpc-one-call-hear: [OK]
mem-rpc-concurrent-call-hear: [OK]
mem-rpc-one-handler: [OK]
mem-rpc-two-handlers: [OK]
mem-rpc-group-call: [OK]
mem-rpc-any-call: [OK]
call-one-with-timeout: [OK]
gcall-three-handlers-with-timeout: [OK]
call-typed-one-with-timeout: [OK]
gcall-typed-three-handlers-with-timeout: [OK]
tcp4-sendReceive: [OK]
tcp4-send2Receive2: [OK]
tcp4-sendReceive-2-serial-servers: [OK]
tcp4-sendReceive-2-serial-clients: [OK]
tcp4-withClient-withServer: [OK]
tcp4-rpc-one-hear-call: [OK]
tcp4-rpc-one-call-hear: [OK]
tcp4-rpc-concurrent-call-hear: [OK]
tcp4-rpc-one-handler: [OK]
tcp4-rpc-two-handlers: [OK]
tcp4-rpc-group-call: [OK]
tcp4-rpc-any-call: [OK]
udp4-sendReceive: [OK]
udp4-send2Receive2: [OK]
udp4-sendReceive-2-serial-servers: [OK]
udp4-sendReceive-2-serial-clients: [OK]
udp4-withClient-withServer: [OK]
udp4-rpc-one-hear-call: [OK]
udp4-rpc-one-call-hear: [OK]
udp4-rpc-concurrent-call-hear: [OK]
udp4-rpc-one-handler: [OK]
udp4-rpc-two-handlers: [OK]
udp4-rpc-group-call: [OK]
udp4-rpc-any-call: [OK]
tcp6-sendReceive: [OK]
tcp6-send2Receive2: [OK]
tcp6-sendReceive-2-serial-servers: [OK]
tcp6-sendReceive-2-serial-clients: [OK]
tcp6-withClient-withServer: [OK]
tcp6-rpc-one-hear-call: [OK]
tcp6-rpc-one-call-hear: [OK]
tcp6-rpc-concurrent-call-hear: [OK]
tcp6-rpc-one-handler: [OK]
tcp6-rpc-two-handlers: [OK]
tcp6-rpc-group-call: [OK]
tcp6-rpc-any-call: [OK]
udp6-sendReceive: [OK]
udp6-send2Receive2: [OK]
udp6-sendReceive-2-serial-servers: [OK]
udp6-sendReceive-2-serial-clients: [OK]
udp6-withClient-withServer: [Failed]
Test should not block
udp6-rpc-one-hear-call: [OK]
udp6-rpc-one-call-hear: [OK]
udp6-rpc-concurrent-call-hear: [OK]
udp6-rpc-one-handler: [OK]
udp6-rpc-two-handlers: [Failed]
Test should not block
udp6-rpc-group-call: [OK]
udp6-rpc-any-call: [OK]
Test Cases Total
Passed 67 67
Failed 2 2
Total 69 69
I ran 3 subsequent build&test steps and it didn't fail again.
I detected that Courier
is not compatible with Network
library version 3.
It happens because Courier
uses the constant Network.Socket.iNADDR_ANY
, which has been decrapted since Network 3.0.
Thus, in the .cabal
file, the network <3
flag must be inserted in the build-depends
library section.
Trying to debug an issue I'm having where running a "server" and connecting to it multiple times, I came up with the following simple echo server / client:
https://gist.github.com/angerman/b541ae09155d8a460648
$ courier-echo server & # works
$ courier-echo client # works
$ courier-echo client # doesn't work any more.
somewhere between the first and second invocation of client
, the server just stalls. Please tell me I did something fundamentally wrong!
Running cabal test
results in this output:
Preprocessing library courier-0.1.1.4...
Preprocessing test suite 'test-courier' for courier-0.1.1.4...
Running 1 test suites...
Test suite test-courier: RUNNING...
test-courier: getAddrInfo: does not exist (nodename nor servname provided, or not known)
Test suite test-courier: FAIL
...
udp4-withClient-withServer: [Failed]
...
Test Cases Total
Passed 44 44
Failed 1 1
Total 45 45
While playing with courier, I learned that unbinding the endpoint, shutting down the transport and exiting, results in potential "final / last" messages getting lost, as the following snipped shows. If a flush
method on the transport would just ensure that the transport had no waiting outgoing messages, and flush
blocking until they are all sent, that would be a great addition, I think. I could also imagine shutdown transport
to block until all outgoing messages are sent.
module Main where
import System.Environment (getArgs)
import Network.Endpoints
import Network.Transport.TCP
import Data.Serialize
import Control.Concurrent (threadDelay)
main :: IO ()
main = do
let master = "master"
slave = "slave"
resolver = resolverFromList [(master, "localhost:2001"),
(slave, "localhost:2000")]
transport <- newTCPTransport resolver
args <- getArgs
case args of
["master"] -> do
endpoint <- newEndpoint [transport]
Right () <- bindEndpoint endpoint master
sendMessage_ endpoint slave $ encode "Hi!"
sendMessage_ endpoint slave $ encode "exit"
-- this receive is here, to ensure the client got
-- the message. And gets a chance to respond.
-- If it wasn't here. The client would neither receive
-- "Hi!" nor "exit" as we are presumably exiting
-- before the messages left the transport.
msg <- receiveMessage endpoint
let Right txt = decode msg
in print $ "[Master] recv: " ++ txt
Right () <- unbindEndpoint endpoint master
shutdown transport
["slave"] -> do
endpoint <- newEndpoint [transport]
Right () <- bindEndpoint endpoint slave
runSlave 0 endpoint $ do { sendMessage_ endpoint master $ encode "And gone..."
-- similarly to the above note, we need to delay for a little to
-- give the transport time to actually push the message, before
-- exiting and thus never delivering it.
; threadDelay 1000
; unbindEndpoint endpoint slave
; shutdown transport }
where
runSlave :: Int -> Endpoint -> IO () -> IO ()
runSlave n endpoint term = do
msg <- receiveMessage endpoint
case decode msg of
Right "exit" -> term
Right txt -> do
print $ "[Slave] recv(" ++ (show n) ++ "): " ++ txt
runSlave (n + 1) endpoint term
Full test run log:
Unpacking to courier-0.1.0.14/
Resolving dependencies...
Configuring courier-0.1.0.14...
Building courier-0.1.0.14...
Preprocessing library courier-0.1.0.14...
[1 of 9] Compiling Network.Transport.Internal ( src/Network/Transport/Internal.hs, dist/build/Network/Transport/Internal.o )
[2 of 9] Compiling Control.Concurrent.Mailbox ( src/Control/Concurrent/Mailbox.hs, dist/build/Control/Concurrent/Mailbox.o )
[3 of 9] Compiling Network.Transport ( src/Network/Transport.hs, dist/build/Network/Transport.o )
[4 of 9] Compiling Network.Transport.Memory ( src/Network/Transport/Memory.hs, dist/build/Network/Transport/Memory.o )
[5 of 9] Compiling Network.Transport.Sockets ( src/Network/Transport/Sockets.hs, dist/build/Network/Transport/Sockets.o )
[6 of 9] Compiling Network.Transport.TCP ( src/Network/Transport/TCP.hs, dist/build/Network/Transport/TCP.o )
[7 of 9] Compiling Network.Transport.UDP ( src/Network/Transport/UDP.hs, dist/build/Network/Transport/UDP.o )
[8 of 9] Compiling Network.Endpoints ( src/Network/Endpoints.hs, dist/build/Network/Endpoints.o )
[9 of 9] Compiling Network.RPC ( src/Network/RPC.hs, dist/build/Network/RPC.o )
In-place registering courier-0.1.0.14...
Preprocessing test suite 'test-courier' for courier-0.1.0.14...
[1 of 7] Compiling TestTransports ( tests/TestTransports.hs, dist/build/test-courier/test-courier-tmp/TestTransports.o )
[2 of 7] Compiling TestRPC ( tests/TestRPC.hs, dist/build/test-courier/test-courier-tmp/TestRPC.o )
[3 of 7] Compiling TestUDP ( tests/TestUDP.hs, dist/build/test-courier/test-courier-tmp/TestUDP.o )
[4 of 7] Compiling TestTCP ( tests/TestTCP.hs, dist/build/test-courier/test-courier-tmp/TestTCP.o )
[5 of 7] Compiling TestMemory ( tests/TestMemory.hs, dist/build/test-courier/test-courier-tmp/TestMemory.o )
[6 of 7] Compiling TestMailbox ( tests/TestMailbox.hs, dist/build/test-courier/test-courier-tmp/TestMailbox.o )
[7 of 7] Compiling Main ( tests/Tests.hs, dist/build/test-courier/test-courier-tmp/Main.o )
Linking dist/build/test-courier/test-courier ...
Building courier-0.1.0.14...
Preprocessing library courier-0.1.0.14...
In-place registering courier-0.1.0.14...
Preprocessing test suite 'test-courier' for courier-0.1.0.14...
Running 1 test suites...
Test suite test-courier: RUNNING...
hunit: [OK]
endpoints: [OK]
mbox-creation: [OK]
mbox-simple-write: [OK]
mbox-write-read: [OK]
mbox-match: [OK]
mbox-find: [OK]
mem-endpoints+transport: [OK]
mem-bind: [OK]
mem-unbind: [OK]
mem-sendReceive: [OK]
mem-transport: [OK]
tcp-endpoints+transport: [OK]
tcp-bind-unbind: [OK]
tcp-send-receive: [OK]
tcp-double-send-receive: [Failed]
ERROR: thread blocked indefinitely in an MVar operation
tcp-send-receive-reply: [OK]
tcp-multiple-send-receive-reply: [OK]
tcp-local-send-receive-reply: [OK]
udp-endpoints+transport: [OK]
udp-bind-unbind: [OK]
udp-send-receive: [OK]
udp-double-send-receive: [OK]
udp-send-receive-reply: [OK]
udp-multiple-send-receive-reply: [OK]
udp-local-send-receive-reply: [OK]
call-one-hear-call: [OK]
call-one-call-hear: [OK]
call-concurrent-call-hear: [OK]
call-one-handler: [OK]
call-two-handlers: [OK]
gcall-three-handlers: [OK]
call-one-with-timeout: [OK]
gcall-three-handlers-with-timeout: [OK]
Test Cases Total
Passed 33 33
Failed 1 1
Total 34 34
Test suite test-courier: FAIL
Test suite logged to: dist/test/courier-0.1.0.14-test-courier.log
0 of 1 test suites (0 of 1 test cases) passed.
Looks like several cases of bad socket handling: some calls on sockets are not interrupted by the cancel of the async in which they are running, and thus the sockets remain open longer than they should, resulting in bind failures in subsequent tests.
Happens in 0.1.0.8.
src/Network/Transport.hs:55:8:
Could not find module GHC.Generics' It is a member of the hidden package
ghc-prim'.
Perhaps you need to add `ghc-prim' to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.
Full log, looks like some files are missing from the sdist tarball:
Unpacking to courier-0.1.0.13/
Resolving dependencies...
Configuring courier-0.1.0.13...
Building courier-0.1.0.13...
Preprocessing library courier-0.1.0.13...
[1 of 9] Compiling Network.Transport.Internal ( src/Network/Transport/Internal.hs, dist/build/Network/Transport/Internal.o )
[2 of 9] Compiling Control.Concurrent.Mailbox ( src/Control/Concurrent/Mailbox.hs, dist/build/Control/Concurrent/Mailbox.o )
[3 of 9] Compiling Network.Transport ( src/Network/Transport.hs, dist/build/Network/Transport.o )
[4 of 9] Compiling Network.Transport.Memory ( src/Network/Transport/Memory.hs, dist/build/Network/Transport/Memory.o )
[5 of 9] Compiling Network.Transport.Sockets ( src/Network/Transport/Sockets.hs, dist/build/Network/Transport/Sockets.o )
[6 of 9] Compiling Network.Transport.TCP ( src/Network/Transport/TCP.hs, dist/build/Network/Transport/TCP.o )
[7 of 9] Compiling Network.Transport.UDP ( src/Network/Transport/UDP.hs, dist/build/Network/Transport/UDP.o )
[8 of 9] Compiling Network.Endpoints ( src/Network/Endpoints.hs, dist/build/Network/Endpoints.o )
[9 of 9] Compiling Network.RPC ( src/Network/RPC.hs, dist/build/Network/RPC.o )
In-place registering courier-0.1.0.13...
Preprocessing test suite 'test-courier' for courier-0.1.0.13...
tests/Tests.hs:20:18:
Could not find module ‘TestMailbox’
Use -v to see a list of the files searched for.
tests/Tests.hs:21:18:
Could not find module ‘TestMemory’
Use -v to see a list of the files searched for.
tests/Tests.hs:22:18:
Could not find module ‘TestTCP’
Use -v to see a list of the files searched for.
tests/Tests.hs:23:18:
Could not find module ‘TestUDP’
Use -v to see a list of the files searched for.
tests/Tests.hs:24:18:
Could not find module ‘TestRPC’
Use -v to see a list of the files searched for.
It's a due to a logic error in UDP bind: we do try to bind to the same socket twice, when we shouldn't.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.