Commit 13b17073 authored by Iustin Pop's avatar Iustin Pop
Browse files

Add NFData instances for query results



This allows us to ensure that query results are strict as we build
them, instead of being lazy and only evaluated when the reply is sent
over the Luxi interface.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarHelga Velroyen <helgav@google.com>
parent daa79414
......@@ -54,6 +54,7 @@ module Ganeti.Query.Language
) where
import Control.Applicative
import Control.DeepSeq
import Data.Foldable
import Data.Traversable (Traversable, traverse, fmapDefault, foldMapDefault)
import Data.Ratio (numerator, denominator)
......@@ -79,6 +80,10 @@ $(declareIADT "ResultStatus"
])
$(makeJSONInstance ''ResultStatus)
-- | No-op 'NFData' instance for 'ResultStatus', since it's a single
-- constructor data-type.
instance NFData ResultStatus
-- | Check that ResultStatus is success or fail with descriptive
-- message.
checkRS :: (Monad m) => ResultStatus -> a -> m a
......@@ -380,6 +385,9 @@ data ResultEntry = ResultEntry
, rentryValue :: Maybe ResultValue -- ^ The (optional) result value
} deriving (Show, Eq)
instance NFData ResultEntry where
rnf (ResultEntry rs rv) = rnf rs `seq` rnf rv
instance JSON ResultEntry where
showJSON (ResultEntry rs rv) =
showJSON (showJSON rs, maybe JSNull showJSON rv)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment