majordomo 0.1.4 → 0.1.5
raw patch · 2 files changed
+26/−12 lines, 2 filesdep ~majordomoPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: majordomo
API changes (from Hackage documentation)
Files
- lib/System/Network/ZMQ/MDP/Client.hs +23/−9
- majordomo.cabal +3/−3
lib/System/Network/ZMQ/MDP/Client.hs view
@@ -27,23 +27,29 @@ -- this can either be XReq or Req...-data ClientSocket = ClientSocket { clientSocket :: Socket Req }+data ClientSocket = ClientSocket { clientSocket :: Socket XReq } data ClientError = ClientTimedOut | ClientBadProtocol withClientSocket :: String -> (ClientSocket -> IO a) -> IO a-withClientSocket socketAddress io =- withContext 1 $ \c -> withSocket c Req $ \s -> do- connect s socketAddress- io (ClientSocket s)-+withClientSocket socketAddress io = do+ outer <- withContext 1 $ \c -> do+ res <- withSocket c XReq $ \s -> do+ connect s socketAddress+ res <- io (ClientSocket s)+ return res+ return res+ return outer+ -- pretty sure there's a nicer way of doing this...-retry :: Monad m => Int -> m (Maybe a) -> m (Maybe a)-retry n action = go n+-- retry :: Monad m => Int -> m (Maybe a) -> m (Maybe a)+retry :: (Eq a1, Num a1) => a1 -> IO (Maybe a) -> IO (Maybe a)+retry n_ action = go n_ where go 0 = return Nothing go n = do+ -- Prelude.putStrLn "Retrying action" result <- action case result of Nothing -> go (n-1)@@ -57,7 +63,12 @@ sendAll sock msgs -- arguably we shouldn't retry if the protocol is bad. -- but i'm disinclined to make the code more complex to cope- maybeprot <- retry 3 $ timeout (1000000 * 3) $ receive sock []+ + -- receive crashes hard when you try to timeout - but later, in zmq_term.+ -- very odd++ maybeprot <- retry 3 $ poll [S sock Z.In] (1000000 * 3) >>= pollExtract+ -- maybeprot <- retry 3 $ timeout (1000000 * 3) $ receive sock [] case maybeprot of Nothing -> return $ Left ClientTimedOut Just "MDPC01" -> do@@ -65,5 +76,8 @@ return $ Right res _ -> return $ Left ClientBadProtocol where+ pollExtract [S s Z.In] = Just <$> receive s [] + pollExtract _ = return Nothing+ sock = clientSocket mdpcs
majordomo.cabal view
@@ -1,5 +1,5 @@ Name: majordomo-Version: 0.1.4+Version: 0.1.5 Synopsis: Majordomo protocol for ZeroMQ Description: The Majordomo Protocol (MDP) defines a reliable service-oriented request-reply dialog between a@@ -26,7 +26,7 @@ Executable mdp_client Main-is: mdp_client.hs- Build-depends: majordomo ==0.1.4, bytestring, cmdargs,base+ Build-depends: majordomo ==0.1.5, bytestring, cmdargs,base hs-source-dirs: src ghc-options: -O2 -threaded @@ -35,7 +35,7 @@ ghc-options: -O2 -threaded ghc-prof-options: -auto-all hs-source-dirs: src- Build-depends: majordomo ==0.1.4,bytestring, + Build-depends: majordomo ==0.1.5,bytestring, threads, unix,base Library