packages feed

amqp 0.3.2 → 0.3.3

raw patch · 2 files changed

+25/−21 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

Network/AMQP.hs view
@@ -118,6 +118,8 @@ import qualified Data.IntMap as IM import qualified Data.ByteString.Char8 as BS import qualified Data.ByteString.Lazy.Char8 as BL+import qualified Data.Sequence as Seq+import qualified Data.Foldable as F import Data.IORef import Data.Maybe import Data.Int@@ -578,8 +580,10 @@                   -- | @openConnection hostname virtualHost loginName loginPassword@ opens a connection to an AMQP server running on @hostname@.--- @virtualHost@ is used as a namespace for AMQP resources (default is \"/\"), so different applications could use multiple virtual hosts on the same AMQP server+-- @virtualHost@ is used as a namespace for AMQP resources (default is \"/\"), so different applications could use multiple virtual hosts on the same AMQP server. --+-- You must call 'closeConnection' before your program exits to ensure that all published messages are received by the server.+-- -- NOTE: If the login name, password or virtual host are invalid, this method will throw a 'ConnectionClosedException'. The exception will not contain a reason why the connection was closed, so you'll have to find out yourself. openConnection :: String -> String -> String -> String -> IO Connection            openConnection host vhost loginName loginPassword =@@ -669,6 +673,8 @@           -- | closes a connection+--+-- Make sure to call this function before your program exits to ensure that all published messages are received by the server. closeConnection :: Connection -> IO () closeConnection c = do     CE.catch (@@ -757,7 +763,7 @@ data Channel = Channel {                     connection :: Connection,                      inQueue :: Chan FramePayload, --incoming frames (from Connection)-                    outstandingResponses :: Chan (MVar Assembly), -- for every request an MVar is stored here waiting for the response+                    outstandingResponses :: MVar (Seq.Seq (MVar Assembly)), -- for every request an MVar is stored here waiting for the response                     channelID :: Word16,                      lastConsumerTag :: MVar Int,                      @@ -790,13 +796,14 @@          if isResponse p         then do-            emp <- isEmptyChan $ outstandingResponses chan-            if emp -                then CE.throwIO $ userError "got response, but have no corresponding request"-                else do-                    x <- readChan (outstandingResponses chan)-                    putMVar x p-        +            action <- modifyMVar (outstandingResponses chan) $ \val -> do+                        case Seq.viewl val of+                            x Seq.:< rest -> do+                                return (rest, putMVar x p)+                            Seq.EmptyL -> do+                                return (val, CE.throwIO $ userError "got response, but have no corresponding request")+            action+         --handle asynchronous assemblies         else handleAsync p @@ -858,15 +865,12 @@         killOutstandingResponses $ outstandingResponses c         return $ Just $ maybe "closed" id x   where -    killOutstandingResponses :: Chan (MVar a) -> IO ()-    killOutstandingResponses chan = do -        emp <- isEmptyChan chan-        if emp -            then return ()-            else do-                x <- readChan chan-                tryPutMVar x $ error "channel closed"-                killOutstandingResponses chan+    killOutstandingResponses :: (MVar (Seq.Seq (MVar a))) -> IO ()+    killOutstandingResponses outResps = do+        modifyMVar_ outResps $ \val -> do+            F.mapM_ (\x -> tryPutMVar x $ error "channel closed") val+            return undefined+             @@ -876,7 +880,7 @@ openChannel :: Connection -> IO Channel openChannel c = do     newInQueue <- newChan-    outRes <- newChan+    outRes <- newMVar Seq.empty     lastConsumerTag <- newMVar 0     ca <- newLock @@ -978,7 +982,7 @@             withMVar (chanClosed chan) $ \cc -> do                 if isNothing cc                     then do-                        writeChan (outstandingResponses chan) res +                        modifyMVar_ (outstandingResponses chan) $ \val -> return $! val Seq.|> res                         writeAssembly' chan m                     else CE.throwIO $ userError "closed" 
amqp.cabal view
@@ -1,5 +1,5 @@ Name:                amqp
-Version:             0.3.2
+Version:             0.3.3
 Synopsis:            Client library for AMQP servers (currently only RabbitMQ)
 Description:         Client library for AMQP servers (currently only RabbitMQ)
 License:             BSD3