From dd3e982c9e9a88533f3e97d3c093eaf12f26c9c9 Mon Sep 17 00:00:00 2001 From: "Scott R. Parish" Date: Tue, 12 Jan 2010 20:05:24 -0600 Subject: [PATCH] s/reqId/reqID to match spec --- Database/MongoDB.hs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/Database/MongoDB.hs b/Database/MongoDB.hs index 6bf6f7d..edd2ee7 100644 --- a/Database/MongoDB.hs +++ b/Database/MongoDB.hs @@ -86,9 +86,9 @@ delete c col sel = do putCol col putI32 0 put sel - (reqId, msg) <- packMsg c OP_DELETE body + (reqID, msg) <- packMsg c OP_DELETE body L.hPut (cHandle c) msg - return reqId + return reqID remove = delete @@ -98,9 +98,9 @@ insert c col doc = do putI32 0 putCol col put doc - (reqId, msg) <- packMsg c OP_INSERT body + (reqID, msg) <- packMsg c OP_INSERT body L.hPut (cHandle c) msg - return reqId + return reqID insertMany :: Connection -> Collection -> [BSONObject] -> IO RequestID insertMany c col docs = do @@ -108,9 +108,9 @@ insertMany c col docs = do putI32 0 putCol col forM_ docs put - (reqId, msg) <- packMsg c OP_INSERT body + (reqID, msg) <- packMsg c OP_INSERT body L.hPut (cHandle c) msg - return reqId + return reqID query :: Connection -> Collection -> NumToSkip -> NumToReturn -> Selector -> Maybe FieldSelector -> IO RequestID @@ -122,23 +122,22 @@ query c col skip ret sel fsel = do putI32 ret put sel put fsel - (reqId, msg) <- packMsg c OP_QUERY body + (reqID, msg) <- packMsg c OP_QUERY body L.hPut (cHandle c) msg - return reqId - + return reqID putCol col = putByteString (pack col) >> putNull packMsg :: Connection -> Opcode -> L.ByteString -> IO (RequestID, L.ByteString) packMsg c op body = do - reqId <- randNum c + reqID <- randNum c let msg = runPut $ do putI32 $ fromIntegral $ L.length body + 16 - putI32 reqId + putI32 reqID putI32 0 putI32 $ fromOpcode op putLazyByteString body - return (reqId, msg) + return (reqID, msg) randNum :: Connection -> IO Int32 randNum Connection { cRand = nsRef } = atomicModifyIORef nsRef $ \ns ->