From a632e8ff55ec7977b1f2871d60f474059434d83a Mon Sep 17 00:00:00 2001 From: Victor Denisov Date: Thu, 26 May 2016 23:03:55 -0700 Subject: [PATCH] Collect size restrictions from the server --- Database/MongoDB/Internal/Protocol.hs | 9 ++++++--- Database/MongoDB/Query.hs | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Database/MongoDB/Internal/Protocol.hs b/Database/MongoDB/Internal/Protocol.hs index 2bf0916..bf647ed 100644 --- a/Database/MongoDB/Internal/Protocol.hs +++ b/Database/MongoDB/Internal/Protocol.hs @@ -91,9 +91,12 @@ data Pipeline = Pipeline } data ServerData = ServerData - { isMaster :: Bool - , minWireVersion :: Int - , maxWireVersion :: Int + { isMaster :: Bool + , minWireVersion :: Int + , maxWireVersion :: Int + , maxMessageSizeBytes :: Int + , maxBsonObjectSize :: Int + , maxWriteBatchSize :: Int } -- | Create new Pipeline over given handle. You should 'close' pipeline when finished, which will also close handle. If pipeline is not closed but eventually garbage collected, it will be closed along with handle. diff --git a/Database/MongoDB/Query.hs b/Database/MongoDB/Query.hs index 2b00e21..7058c4b 100644 --- a/Database/MongoDB/Query.hs +++ b/Database/MongoDB/Query.hs @@ -304,6 +304,9 @@ retrieveServerData = do { isMaster = (fromMaybe False $ lookup "ismaster" d) , minWireVersion = (fromMaybe 0 $ lookup "minWireVersion" d) , maxWireVersion = (fromMaybe 0 $ lookup "maxWireVersion" d) + , maxMessageSizeBytes = (fromMaybe 48000000 $ lookup "maxMessageSizeBytes" d) + , maxBsonObjectSize = (fromMaybe (16 * 1024 * 1024) $ lookup "maxBsonObjectSize" d) + , maxWriteBatchSize = (fromMaybe 1000 $ lookup "maxWriteBatchSize" d) } return newSd