...to make sure we can successfully build on platforms
with older versions of the containers library.

Signed-off-by: Klaus Aehlig <aeh...@google.com>
---
 src/Ganeti/DataCollectors/Types.hs | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/Ganeti/DataCollectors/Types.hs 
b/src/Ganeti/DataCollectors/Types.hs
index 59c5e8c..c58e659 100644
--- a/src/Ganeti/DataCollectors/Types.hs
+++ b/src/Ganeti/DataCollectors/Types.hs
@@ -50,6 +50,7 @@ module Ganeti.DataCollectors.Types
   ) where
 
 import Control.DeepSeq (NFData, rnf, force)
+import Control.Seq (using, seqFoldable, rdeepseq)
 import Data.Char
 import Data.Ratio
 import qualified Data.Map as Map
@@ -139,9 +140,25 @@ instance JSON DCVersion where
 -- | Type for the value field of the `CollectorMap` below.
 data CollectorData = CPULoadData (Seq.Seq (Integer, [Int]))
 
+{-
+
+Naturally, we want to make CollectorData an instance of NFData as
+follows.
+
 instance NFData CollectorData where
   rnf (CPULoadData x) = rnf x
 
+However, Seq.Seq only became an instance of NFData in version 0.5.0.0
+of containers (Released 2012). So, for the moment, we use a generic
+way to reduce to normal form. In later versions of Ganeti, where we
+have the infra structure to do so, we will choose implementation depending
+on the version of the containers library available.
+
+-}
+
+instance NFData CollectorData where
+  rnf (CPULoadData x) =  (x `using` seqFoldable rdeepseq) `seq` ()
+
 -- | Type for the map storing the data of the statefull DataCollectors.
 type CollectorMap = Map.Map String CollectorData
 
-- 
2.2.0.rc0.207.ga3a616c

Reply via email to