packages feed

majordomo 0.1.5 → 0.1.6

raw patch · 3 files changed

+9/−19 lines, 3 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 view
@@ -27,7 +27,7 @@   -- this can either be XReq or Req...-data ClientSocket = ClientSocket { clientSocket :: Socket XReq }+data ClientSocket = ClientSocket { clientSocket :: Socket Req }   data ClientError = ClientTimedOut@@ -36,25 +36,13 @@ withClientSocket :: String -> (ClientSocket -> IO a) -> IO a withClientSocket socketAddress io = do   outer <- withContext 1 $ \c -> do-    res <- withSocket c XReq $ \s -> do+    res <- withSocket c Req $ \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 :: (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)-            Just x -> return $ Just x-     sendAndReceive :: ClientSocket -> ByteString -> [ByteString] -> IO (Either ClientError Response) sendAndReceive mdpcs svc msgs =   do -- Z.send sock "" [SndMore]@@ -66,8 +54,9 @@            -- 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+     -- following the design of the c client, we use a Req socket, +     -- and only try once.+     maybeprot <- poll [S sock Z.In] (1000000 * 3) >>= pollExtract      -- maybeprot <- retry 3 $ timeout (1000000 * 3) $ receive sock []      case maybeprot of        Nothing -> return $ Left ClientTimedOut
majordomo.cabal view
@@ -1,5 +1,5 @@ Name:                majordomo-Version:             0.1.5+Version:             0.1.6 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.5, bytestring, cmdargs,base+  Build-depends: majordomo ==0.1.6, 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.5,bytestring, +  Build-depends: majordomo ==0.1.6,bytestring,                   threads, unix,base  Library
src/mdp_client.hs view
@@ -28,6 +28,7 @@     else C.withClientSocket (broker s) $ \sock -> do       res <- C.sendAndReceive sock (pack $ service s) (Prelude.map pack $ message_parts s)       putStr $ case res of+        -- nb we really should try more than once.         Left C.ClientTimedOut    ->  "Timed out!"         Left C.ClientBadProtocol -> "Bad protocol!"         Right l ->  BS.concat . L.intersperse "\n" $ C.response l