git.iko.soy/typeable/bloodhound
on master help sign in
Merge pull request #139 from bermanjosh/nodePluginVersion
7d718efChris Allen
bloodhound.cabal+1−1
@@ -1,5 +1,5 @@
1name: bloodhound
1name: bloodhound
2−version: 0.11.1.0
2+version: 0.12.0.0
3synopsis: ElasticSearch client library for Haskell
3synopsis: ElasticSearch client library for Haskell
4description: ElasticSearch made awesome for Haskell hackers
4description: ElasticSearch made awesome for Haskell hackers
5homepage: https://github.com/bitemyapp/bloodhound
5homepage: https://github.com/bitemyapp/bloodhound
changelog.md+5
@@ -1,3 +1,8 @@
1+0.12.0.0
2+===================
3+* #138 Make `nodeOSLoad` record a `Maybe` for Windows compatibility
4+* #138 Change the `nodePluginVersion` record to deal with plugins which report `NA` as their version.
5+
10.11.0.0
60.11.0.0
2===================
7===================
3
8
src/Database/Bloodhound/Types.hs+15−7
@@ -62,6 +62,7 @@ module Database.Bloodhound.Types
62 , MonadBH(..)
62 , MonadBH(..)
63 , Version(..)
63 , Version(..)
64 , VersionNumber(..)
64 , VersionNumber(..)
65+ , MaybeNA(..)
65 , BuildHash(..)
66 , BuildHash(..)
66 , Status(..)
67 , Status(..)
67 , Existence(..)
68 , Existence(..)
@@ -4064,7 +4065,7 @@ data NodeOSStats = NodeOSStats {
4064 , nodeOSCPUIdle :: Int
4065 , nodeOSCPUIdle :: Int
4065 , nodeOSCPUUser :: Int
4066 , nodeOSCPUUser :: Int
4066 , nodeOSCPUSys :: Int
4067 , nodeOSCPUSys :: Int
4067− , nodeOSLoad :: LoadAvgs
4068+ , nodeOSLoad :: Maybe LoadAvgs
4068 , nodeOSUptime :: NominalDiffTime
4069 , nodeOSUptime :: NominalDiffTime
4069 , nodeOSTimestamp :: UTCTime
4070 , nodeOSTimestamp :: UTCTime
4070 } deriving (Eq, Show, Generic, Typeable)
4071 } deriving (Eq, Show, Generic, Typeable)
@@ -4189,7 +4190,7 @@ data NodePluginInfo = NodePluginInfo {
4189 , nodePluginJVM :: Bool
4190 , nodePluginJVM :: Bool
4190 -- ^ Is this plugin running on the JVM
4191 -- ^ Is this plugin running on the JVM
4191 , nodePluginDescription :: Text
4192 , nodePluginDescription :: Text
4192− , nodePluginVersion :: VersionNumber
4193+ , nodePluginVersion :: MaybeNA VersionNumber
4193 , nodePluginName :: PluginName
4194 , nodePluginName :: PluginName
4194 } deriving (Eq, Show, Generic, Typeable)
4195 } deriving (Eq, Show, Generic, Typeable)
4195
4196
@@ -4875,7 +4876,7 @@ instance FromJSON NodeOSStats where
4875 swap <- o .: "swap"
4876 swap <- o .: "swap"
4876 mem <- o .: "mem"
4877 mem <- o .: "mem"
4877 cpu <- o .: "cpu"
4878 cpu <- o .: "cpu"
4878− load <- o .: "load_average"
4879+ load <- o .:? "load_average"
4879 NodeOSStats <$> swap .: "free_in_bytes"
4880 NodeOSStats <$> swap .: "free_in_bytes"
4880 <*> swap .: "used_in_bytes"
4881 <*> swap .: "used_in_bytes"
4881 <*> mem .: "actual_used_in_bytes"
4882 <*> mem .: "actual_used_in_bytes"
@@ -5044,11 +5045,11 @@ parseNodeInfo nid o =
5044instance FromJSON NodePluginInfo where
5045instance FromJSON NodePluginInfo where
5045 parseJSON = withObject "NodePluginInfo" parse
5046 parseJSON = withObject "NodePluginInfo" parse
5046 where
5047 where
5047− parse o = NodePluginInfo <$> o .: "site"
5048+ parse o = NodePluginInfo <$> o .: "site"
5048− <*> o .: "jvm"
5049+ <*> o .: "jvm"
5049− <*> o .: "description"
5050+ <*> o .: "description"
5050 <*> o .: "version"
5051 <*> o .: "version"
5051− <*> o .: "name"
5052+ <*> o .: "name"
5052
5053
5053instance FromJSON NodeHTTPInfo where
5054instance FromJSON NodeHTTPInfo where
5054 parseJSON = withObject "NodeHTTPInfo" parse
5055 parseJSON = withObject "NodeHTTPInfo" parse
@@ -5212,3 +5213,10 @@ instance FromJSON NodeNetworkInterface where
5212 parse o = NodeNetworkInterface <$> o .: "mac_address"
5213 parse o = NodeNetworkInterface <$> o .: "mac_address"
5213 <*> o .: "name"
5214 <*> o .: "name"
5214 <*> o .: "address"
5215 <*> o .: "address"
5216+
5217+newtype MaybeNA a = MaybeNA { unMaybeNA :: Maybe a }
5218+ deriving (Show, Eq)
5219+
5220+instance FromJSON a => FromJSON (MaybeNA a) where
5221+ parseJSON (String "NA") = pure $ MaybeNA Nothing
5222+ parseJSON o = MaybeNA . Just <$> parseJSON o