packages feed

influxdb 0.8.0 → 0.9.0

raw patch · 6 files changed

+29/−27 lines, 6 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Database.InfluxDB: listInterfaces :: Config -> IO [Text]
- Database.InfluxDB.Http: listInterfaces :: Config -> IO [Text]
+ Database.InfluxDB.Decode: fromSeriesData_ :: FromSeriesData a => SeriesData -> [a]

Files

CHANGELOG.md view
@@ -1,3 +1,9 @@+## v0.9.0 - 2014-11-27++* The `Value` parsers (accidentally) could throw exceptions. It's fixed now.+* Add `fromSeriesData_` which discards parsing errors and returns only successful data+* Remove `listInterfaces`+ ## v0.8.0 - 2014-11-07  * Retry on connection failure and response timeout in addition to IOException
influxdb.cabal view
@@ -1,5 +1,5 @@ name: influxdb-version: 0.8.0+version: 0.9.0 synopsis: Haskell client library for InfluxDB description: Haskell client library for InfluxDB homepage: https://github.com/maoe/influxdb-haskell@@ -153,5 +153,5 @@  source-repository this   type: git-  tag: v0.8.0+  tag: v0.9.0   location: https://github.com/maoe/influxdb-haskell.git
src/Database/InfluxDB.hs view
@@ -84,7 +84,6 @@    -- *** Other API   , ping-  , listInterfaces   , isInSync   ) where 
src/Database/InfluxDB/Decode.hs view
@@ -4,13 +4,14 @@ {-# LANGUAGE TypeSynonymInstances #-} module Database.InfluxDB.Decode   ( FromSeries(..), fromSeries-  , FromSeriesData(..), fromSeriesData+  , FromSeriesData(..), fromSeriesData, fromSeriesData_   , withValues, (.:), (.:?), (.!=)   , FromValue(..), fromValue   , Parser, ValueParser, typeMismatch   ) where import Control.Applicative import Control.Monad.Reader+import Data.Either (rights) import Data.Int import Data.Word import Data.Map (Map)@@ -68,6 +69,13 @@   (runParser . parseSeriesData seriesDataColumns)   seriesDataPoints +-- | Same as @fromSeriesData@ but ignores parse errors and returns only+-- successful data.+fromSeriesData_ :: FromSeriesData a => SeriesData -> [a]+fromSeriesData_ SeriesData {..} = rights $ map+  (runParser . parseSeriesData seriesDataColumns)+  seriesDataPoints+ -- | Helper function to define 'parseSeriesData' from 'ValueParser's. withValues   :: (Vector Value -> ValueParser a)@@ -84,7 +92,7 @@ values .: column = do   found <- asks $ Map.lookup column   case found of-    Nothing -> fail $ "No such column: " ++ T.unpack column+    Nothing -> liftParser $ parseError $ "No such column: " ++ T.unpack column     Just idx -> do       value <- V.indexM values idx       liftParser $ parseValue value@@ -133,43 +141,43 @@ instance FromValue Int8 where   parseValue (Int n)     | n <= fromIntegral (maxBound :: Int8) = return $ fromIntegral n-    | otherwise = fail $ "Larger than the maximum Int8: " ++ show n+    | otherwise = parseError $ "Larger than the maximum Int8: " ++ show n   parseValue v = typeMismatch "Int8" v  instance FromValue Int16 where   parseValue (Int n)     | n <= fromIntegral (maxBound :: Int16) = return $ fromIntegral n-    | otherwise = fail $ "Larger than the maximum Int16: " ++ show n+    | otherwise = parseError $ "Larger than the maximum Int16: " ++ show n   parseValue v = typeMismatch "Int16" v  instance FromValue Int32 where   parseValue (Int n)     | n <= fromIntegral (maxBound :: Int32) = return $ fromIntegral n-    | otherwise = fail $ "Larger than the maximum Int32: " ++ show n+    | otherwise = parseError $ "Larger than the maximum Int32: " ++ show n   parseValue v = typeMismatch "Int32" v  instance FromValue Int64 where   parseValue (Int n)     | n <= fromIntegral (maxBound :: Int64) = return $ fromIntegral n-    | otherwise = fail $ "Larger than the maximum Int64: " ++ show n+    | otherwise = parseError $ "Larger than the maximum Int64: " ++ show n   parseValue v = typeMismatch "Int64" v  instance FromValue Word8 where   parseValue (Int n)     | n <= fromIntegral (maxBound :: Word8) = return $ fromIntegral n-    | otherwise = fail $ "Larger than the maximum Word8: " ++ show n+    | otherwise = parseError $ "Larger than the maximum Word8: " ++ show n   parseValue v = typeMismatch "Word8" v  instance FromValue Word16 where   parseValue (Int n)     | n <= fromIntegral (maxBound :: Word16) = return $ fromIntegral n-    | otherwise = fail $ "Larger than the maximum Word16: " ++ show n+    | otherwise = parseError $ "Larger than the maximum Word16: " ++ show n   parseValue v = typeMismatch "Word16" v  instance FromValue Word32 where   parseValue (Int n)     | n <= fromIntegral (maxBound :: Word32) = return $ fromIntegral n-    | otherwise = fail $ "Larger than the maximum Word32: " ++ show n+    | otherwise = parseError $ "Larger than the maximum Word32: " ++ show n   parseValue v = typeMismatch "Word32" v  instance FromValue Double where@@ -196,7 +204,7 @@   :: String   -> Value   -> Parser a-typeMismatch expected actual = fail $+typeMismatch expected actual = parseError $   "when expecting a " ++ expected ++   ", encountered " ++ name ++ " instead"   where@@ -218,3 +226,6 @@  liftParser :: Parser a -> ValueParser a liftParser = ValueParser . ReaderT . const++parseError :: String -> Parser a+parseError = Parser . Left
src/Database/InfluxDB/Http.hs view
@@ -61,7 +61,6 @@    -- ** Other API   , ping-  , listInterfaces   , isInSync   ) where @@ -698,14 +697,6 @@   where     request = def       { HC.path = "/ping"-      }---- | Fetch current list of available interfaces-listInterfaces :: Config -> IO [Text]-listInterfaces config = runRequest config request-  where-    request = def-      { HC.path = "/interfaces"       }  isInSync :: Config -> IO Bool
tests/test-suite.hs view
@@ -95,11 +95,6 @@   Ping status <- ping config   status @?= "ok" -case_listInterfaces :: Assertion-case_listInterfaces = runTest $ \config -> do-  ifaces <- listInterfaces config-  ifaces @?= ["default"]- case_isInSync :: Assertion case_isInSync = runTest $ \config -> do   inSync <- isInSync config