aws-kinesis 0.1 → 0.1.1
raw patch · 7 files changed
+88/−14 lines, 7 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Aws.Kinesis.Commands.DescribeStream: instance IteratedTransaction DescribeStream DescribeStreamResponse
+ Aws.Kinesis.Commands.DescribeStream: instance ListResponse DescribeStreamResponse Shard
+ Aws.Kinesis.Commands.GetRecords: instance IteratedTransaction GetRecords GetRecordsResponse
+ Aws.Kinesis.Commands.GetRecords: instance ListResponse GetRecordsResponse Record
+ Aws.Kinesis.Commands.ListStreams: instance IteratedTransaction ListStreams ListStreamsResponse
+ Aws.Kinesis.Commands.ListStreams: instance ListResponse ListStreamsResponse StreamName
Files
- CHANGELOG.md +8/−0
- aws-kinesis.cabal +2/−2
- constraints +1/−1
- src/Aws/Kinesis/Commands/DescribeStream.hs +30/−0
- src/Aws/Kinesis/Commands/GetRecords.hs +10/−0
- src/Aws/Kinesis/Commands/ListStreams.hs +28/−0
- tests/Utils.hs +9/−11
CHANGELOG.md view
@@ -1,3 +1,11 @@+0.1.1+=====++* Add `IteratedTransaction` and `ListResponse` instances for+ `DescribeStream`, `GetRecords`, and `ListStreams`.++* Fix recognition of test failures.+ 0.1 ===
aws-kinesis.cabal view
@@ -3,7 +3,7 @@ -- ------------------------------------------------------ -- Name: aws-kinesis-Version: 0.1+Version: 0.1.1 Synopsis: Bindings for AWS Kinesis Version 2013-12-02 description: Bindings for AWS Kinesis@@ -38,7 +38,7 @@ source-repository this type: git location: https://github.com/alephcloud/hs-aws-kinesis.git- tag: 0.1+ tag: 0.1.1 Library default-language: Haskell2010
constraints view
@@ -8,7 +8,7 @@ attoparsec-conduit ==1.1.0, aws ==0.9.2, aws-general ==0.1.1,- aws-kinesis ==0.1,+ aws-kinesis ==0.1.1, base ==4.7.0.1, base16-bytestring ==0.1.1.6, base64-bytestring ==1.0.0.1,
src/Aws/Kinesis/Commands/DescribeStream.hs view
@@ -53,6 +53,7 @@ import Data.Aeson import qualified Data.ByteString.Lazy as LB+import Data.Maybe import Data.Typeable describeStreamAction :: KinesisAction@@ -105,6 +106,35 @@ instance AsMemoryResponse DescribeStreamResponse where type MemoryResponse DescribeStreamResponse = DescribeStreamResponse loadToMemory = return++instance ListResponse DescribeStreamResponse Shard where+ listResponse DescribeStreamResponse{..} =+ streamDescriptionShards describeStreamResStreamDescription++-- | This instance assumes that the returned 'StreamDescription' contains at least one+-- shard if available, i.e. if @streamDescriptionResHasMoreShards == True@.+--+-- Otherwise, in case no shard is returned but+-- @streamDescriptionHasMoreShards == True@ the implementation in this instance+-- returns Nothing, thus ignoring the value of 'streamDescriptionHasMoreShards'.+-- The alternatives would be to either throw an exception or to start over+-- with a reqeust for the first set of shards which could result in a+-- non-terminating behavior.+--+-- The request parameter 'describeStreamLimit' is interpreted as limit for each+-- single request and not for the overall transaction.+--+instance IteratedTransaction DescribeStream DescribeStreamResponse where+ nextIteratedRequest req@DescribeStream{..} res+ | streamDescriptionHasMoreShards streamDesc && isJust exclStartShardId = Just req+ { describeStreamExclusiveStartShardId = exclStartShardId+ }+ | otherwise = Nothing+ where+ streamDesc = describeStreamResStreamDescription res+ exclStartShardId = case streamDescriptionShards streamDesc of+ [] -> Nothing+ t -> Just . shardShardId . last $ t -- -------------------------------------------------------------------------- -- -- Exceptions
src/Aws/Kinesis/Commands/GetRecords.hs view
@@ -119,6 +119,16 @@ type MemoryResponse GetRecordsResponse = GetRecordsResponse loadToMemory = return +instance ListResponse GetRecordsResponse Record where+ listResponse (GetRecordsResponse _ records) = records++-- | The request parameter 'getRecordsLimit' is interpreted as limit for each+-- single request and not for the overall transaction.+--+instance IteratedTransaction GetRecords GetRecordsResponse where+ nextIteratedRequest GetRecords{..} GetRecordsResponse{..} =+ GetRecords getRecordsLimit <$> getRecordsResNextShardIterator+ -- -------------------------------------------------------------------------- -- -- Exceptions --
src/Aws/Kinesis/Commands/ListStreams.hs view
@@ -50,6 +50,7 @@ import Data.Aeson import qualified Data.ByteString.Lazy as LB+import Data.Maybe import Data.Typeable listStreamsAction :: KinesisAction@@ -101,6 +102,33 @@ instance AsMemoryResponse ListStreamsResponse where type MemoryResponse ListStreamsResponse = ListStreamsResponse loadToMemory = return++instance ListResponse ListStreamsResponse StreamName where+ listResponse (ListStreamsResponse _ streams) = streams++-- | This instance assumes that 'ListStreams' returns at least one+-- stream if available, i.e. if @listStreamsResHasMoreStreams == True@.+--+-- Otherwise, in case no stream is returned but+-- @listStreamsResHasMoreStreams == True@ the implementation in this instance+-- returns Nothing, thus ignoring the value of 'listStreamsResHasMoreStreams'.+-- The alternatives would be to either throw an exception or to start over+-- with a reqeust for the first set of streams which could result in a+-- non-terminating behavior.+--+-- The request parameter 'listStreamsLimit' is interpreted as limit for each+-- single request and not for the overall transaction.+--+instance IteratedTransaction ListStreams ListStreamsResponse where+ nextIteratedRequest req@ListStreams{..} ListStreamsResponse{..}+ | listStreamsResHasMoreStreams && isJust exclStartStream = Just req+ { listStreamsExclusiveStartStreamName = exclStartStream+ }+ | otherwise = Nothing+ where+ exclStartStream = case listStreamsResStreamNames of+ [] -> Nothing+ t -> Just $ last t -- -------------------------------------------------------------------------- -- -- Exceptions
tests/Utils.hs view
@@ -55,8 +55,6 @@ import Test.Tasty import Test.Tasty.QuickCheck -import System.IO- -- -------------------------------------------------------------------------- -- -- Static Test parameters --@@ -96,32 +94,32 @@ :: Functor f => String -- ^ test name -> f (EitherT T.Text IO a) -- ^ test- -> f (IO Bool)+ -> f (PropertyM IO Bool) evalTestTM name = fmap $- runEitherT >=> \r -> case r of- Left e -> do- hPutStrLn stderr $ "failed to run stream test \"" <> name <> "\": " <> show e- return False+ (liftIO . runEitherT) >=> \r -> case r of+ Left e ->+ fail $ "failed to run test \"" <> name <> "\": " <> show e Right _ -> return True evalTestT :: String -- ^ test name -> EitherT T.Text IO a -- ^ test- -> IO Bool+ -> PropertyM IO Bool evalTestT name = runIdentity . evalTestTM name . Identity eitherTOnceTest0 :: String -- ^ test name -> EitherT T.Text IO a -- ^ test -> TestTree-eitherTOnceTest0 name = testProperty name . once . ioProperty . evalTestT name+eitherTOnceTest0 name test = testProperty name . once . monadicIO+ $ evalTestT name test eitherTOnceTest1 :: (Arbitrary a, Show a) => String -- ^ test name -> (a -> EitherT T.Text IO b) -> TestTree-eitherTOnceTest1 name test = testProperty name . once $ monadicIO . liftIO+eitherTOnceTest1 name test = testProperty name . once $ monadicIO . evalTestTM name test eitherTOnceTest2@@ -129,7 +127,7 @@ => String -- ^ test name -> (a -> b -> EitherT T.Text IO c) -> TestTree-eitherTOnceTest2 name test = testProperty name . once $ \a b -> monadicIO . liftIO+eitherTOnceTest2 name test = testProperty name . once $ \a b -> monadicIO $ (evalTestTM name $ uncurry test) (a, b) -- -------------------------------------------------------------------------- --