hs-aws-lambda 0.1.0.1 → 0.1.0.2
raw patch · 3 files changed
+26/−29 lines, 3 filesdep +hs-aws-lambdadep −aws-lambda-runtime-apidep −text-conversionsPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: hs-aws-lambda
Dependencies removed: aws-lambda-runtime-api, text-conversions
API changes (from Hackage documentation)
- AWS.Lambda.RuntimeAPI.Types: class FromText a
- AWS.Lambda.RuntimeAPI.Types: class ToText a
- AWS.Lambda.RuntimeAPI.Types: convertText :: (ToText a, FromText b) => a -> b
- AWS.Lambda.RuntimeAPI.Types: ct :: (ToText a, FromText b) => a -> b
+ AWS.Lambda.RuntimeAPI.Types: instance GHC.Show.Show AWS.Lambda.RuntimeAPI.Types.MobileInvocationMetadata
+ AWS.Lambda.RuntimeAPI.Types: instance GHC.Show.Show payload => GHC.Show.Show (AWS.Lambda.RuntimeAPI.Types.LambdaInvocation payload)
+ AWS.Lambda.RuntimeAPI.Types: instance GHC.Show.Show payload => GHC.Show.Show (AWS.Lambda.RuntimeAPI.Types.LambdaResult payload)
Files
- hs-aws-lambda.cabal +6/−9
- src/AWS/Lambda/RuntimeAPI.hs +17/−10
- src/AWS/Lambda/RuntimeAPI/Types.hs +3/−10
hs-aws-lambda.cabal view
@@ -5,9 +5,9 @@ -- see: https://github.com/sol/hpack name: hs-aws-lambda-version: 0.1.0.1+version: 0.1.0.2 synopsis: A modern and easy-to-use wrapper for Docker-based Lambda implementations-description: Please see the README on GitHub at <https://github.com/RobertFischer/aws-lambda-runtime-api#readme>+description: Please see the README on GitHub at <https://github.com/RobertFischer/hs-aws-lambda#readme> category: AWS homepage: https://github.com/RobertFischer/hs-aws-lambda#readme bug-reports: https://github.com/RobertFischer/hs-aws-lambda/issues@@ -36,7 +36,7 @@ hs-source-dirs: src default-extensions: BangPatterns BinaryLiterals CPP ConstraintKinds DataKinds DefaultSignatures DeriveAnyClass DeriveDataTypeable DeriveFoldable DeriveFunctor DeriveGeneric DeriveLift DeriveTraversable DoAndIfThenElse EmptyDataDecls ExistentialQuantification ExtendedDefaultRules FlexibleContexts FlexibleInstances ForeignFunctionInterface FunctionalDependencies GADTs GeneralizedNewtypeDeriving InstanceSigs KindSignatures LambdaCase MagicHash MultiParamTypeClasses MultiWayIf NamedFieldPuns OverloadedLists OverloadedStrings PackageImports PartialTypeSignatures PatternGuards PolyKinds QuasiQuotes RankNTypes RecordWildCards ScopedTypeVariables StandaloneDeriving StaticPointers TemplateHaskell TupleSections TypeFamilies TypeOperators TypeSynonymInstances UnboxedTuples UnliftedFFITypes ViewPatterns TypeFamilyDependencies- ghc-options: -Wall -Wincomplete-record-updates -Wincomplete-uni-patterns -fprint-expanded-synonyms -fprint-explicit-coercions -fprint-equality-relations -fprint-typechecker-elaboration -freverse-errors -funclutter-valid-hole-fits -fhelpful-errors -fshow-warning-groups -fPIC -fno-warn-tabs -fno-warn-type-defaults -Werror=compat -Werror=partial-fields -Werror=missing-fields -Werror=incomplete-patterns -Werror=overlapping-patterns -Werror=redundant-constraints -feager-blackholing -fexcess-precision -flate-dmd-anal -fmax-inline-alloc-size=1024 -fmax-simplifier-iterations=16 -fsimplifier-phases=8 -fspec-constr-keen -fspec-constr-count=12 -fspecialise-aggressively -flate-specialise -fstatic-argument-transformation+ ghc-options: -Wall -Wincomplete-record-updates -Wincomplete-uni-patterns -fprint-expanded-synonyms -fprint-explicit-coercions -fprint-equality-relations -fprint-typechecker-elaboration -freverse-errors -funclutter-valid-hole-fits -fhelpful-errors -fshow-warning-groups -fPIC -fno-warn-tabs -fno-warn-type-defaults -Werror=compat -Werror=partial-fields -Werror=missing-fields -Werror=incomplete-patterns -Werror=overlapping-patterns -Werror=redundant-constraints -Werror=missing-methods -feager-blackholing -fexcess-precision -flate-dmd-anal -fmax-inline-alloc-size=1024 -fmax-simplifier-iterations=16 -fsimplifier-phases=8 -fspec-constr-keen -fspec-constr-count=12 -fspecialise-aggressively -flate-specialise -fstatic-argument-transformation build-depends: aeson , base >=4.7 && <5@@ -48,7 +48,6 @@ , http-types , safe-exceptions , text- , text-conversions , unliftio default-language: Haskell2010 @@ -57,13 +56,11 @@ main-is: Spec.hs other-modules: Paths_hs_aws_lambda- autogen-modules:- Paths_hs_aws_lambda hs-source-dirs: test default-extensions: BangPatterns BinaryLiterals CPP ConstraintKinds DataKinds DefaultSignatures DeriveAnyClass DeriveDataTypeable DeriveFoldable DeriveFunctor DeriveGeneric DeriveLift DeriveTraversable DoAndIfThenElse EmptyDataDecls ExistentialQuantification ExtendedDefaultRules FlexibleContexts FlexibleInstances ForeignFunctionInterface FunctionalDependencies GADTs GeneralizedNewtypeDeriving InstanceSigs KindSignatures LambdaCase MagicHash MultiParamTypeClasses MultiWayIf NamedFieldPuns OverloadedLists OverloadedStrings PackageImports PartialTypeSignatures PatternGuards PolyKinds QuasiQuotes RankNTypes RecordWildCards ScopedTypeVariables StandaloneDeriving StaticPointers TemplateHaskell TupleSections TypeFamilies TypeOperators TypeSynonymInstances UnboxedTuples UnliftedFFITypes ViewPatterns TypeFamilyDependencies- ghc-options: -Wall -Wincomplete-record-updates -Wincomplete-uni-patterns -fprint-expanded-synonyms -fprint-explicit-coercions -fprint-equality-relations -fprint-typechecker-elaboration -freverse-errors -funclutter-valid-hole-fits -fhelpful-errors -fshow-warning-groups -fPIC -fno-warn-tabs -fno-warn-type-defaults -Werror=compat -Werror=partial-fields -Werror=missing-fields -Werror=incomplete-patterns -Werror=overlapping-patterns -Werror=redundant-constraints -threaded -rtsopts -with-rtsopts=-N+ ghc-options: -Wall -Wincomplete-record-updates -Wincomplete-uni-patterns -fprint-expanded-synonyms -fprint-explicit-coercions -fprint-equality-relations -fprint-typechecker-elaboration -freverse-errors -funclutter-valid-hole-fits -fhelpful-errors -fshow-warning-groups -fPIC -fno-warn-tabs -fno-warn-type-defaults -Werror=compat -Werror=partial-fields -Werror=missing-fields -Werror=incomplete-patterns -Werror=overlapping-patterns -Werror=redundant-constraints -Werror=missing-methods -threaded -rtsopts -with-rtsopts=-N build-depends:- aws-lambda-runtime-api- , base >=4.7 && <5+ base >=4.7 && <5+ , hs-aws-lambda default-language: Haskell2010
src/AWS/Lambda/RuntimeAPI.hs view
@@ -15,7 +15,14 @@ import qualified Network.HTTP.Client.Internal as HTTP import qualified Network.HTTP.Types.Header as HTTP import qualified Network.HTTP.Types.Status as HTTP+import qualified Data.Text as Text +cts :: Text -> String+cts = Text.unpack++cst :: String -> Text+cst = Text.pack+ mkLambdaHeaderName :: (CI.FoldCase s, Semigroup s, IsString s) => s -> CI.CI s mkLambdaHeaderName str = CI.mk $ "Lambda-Runtime-" <> str @@ -75,7 +82,7 @@ getNextInvocation = handleAnyDeep handleTopException ( Just <$> fetchNext ctx ) handler = lecHandler ctx processRequest invoc = handleAnyDeep handleException $ handler invoc- handleException e = return $ LambdaError (ct $ exToTypeStr e, ct $ exToHumanStr e)+ handleException e = return $ LambdaError (cst $ exToTypeStr e, cst $ exToHumanStr e) handleTopException err = handleInvocationException ctx err >> return Nothing exToTypeStr :: (Exception e) => e -> String@@ -132,23 +139,23 @@ response <- liftIO $ HTTP.httpLbs req lecHttpManager checkResponseStatus response liPayload <- readPayload response- liAwsRequestId <- readHeader response requestIdHeader+ liAwsRequestId <- cst <$> readHeader response requestIdHeader liDeadlineMs <- readDeadline response- liInvokedFunctionArn <- readHeader response invokedFunctionArnHeader- liTraceId <- readHeader response traceIdHeader+ liInvokedFunctionArn <- cst <$> readHeader response invokedFunctionArnHeader+ liTraceId <- cst <$> readHeader response traceIdHeader let liMobileMetadata = readMobileMetadata response return $ LambdaInvocation{..} where url = lecApiPrefix <> "/runtime/invocation/next" readMobileMetadata response = do- mimClientContext <- readHeader response clientContextHeader- mimCognitoIdentity <- readHeader response cognitoIdentityHeader+ mimClientContext <- cst <$> readHeader response clientContextHeader+ mimCognitoIdentity <- cst <$> readHeader response cognitoIdentityHeader return $ MobileInvocationMetadata{..} readHeader response headerName = let headers = HTTP.responseHeaders response in let finder (otherHeaderName, _) = headerName == otherHeaderName in case find finder headers of- Just (_,value) -> return . ct $ C8.unpack value+ Just (_,value) -> return $ C8.unpack value Nothing -> fail $ "Could not find header: " <> show headerName readDeadline response = do headerValue <- readHeader response "Lambda-Runtime-Deadline-Ms"@@ -184,12 +191,12 @@ case result of LambdaNop -> return () (LambdaSuccess payload) -> do- let url = lecApiPrefix <> "/runtime/invocation/" <> ct liAwsRequestId <> "/response"+ let url = lecApiPrefix <> "/runtime/invocation/" <> cts liAwsRequestId <> "/response" let body = Just payload req <- addTraceId <$> makeHttpRequest "POST" url body void . liftIO $ HTTP.httpNoBody req lecHttpManager LambdaError (errType, errMsg) -> do- let url = lecApiPrefix <> "/runtime/invocation/" <> ct liAwsRequestId <> "/error"+ let url = lecApiPrefix <> "/runtime/invocation/" <> cts liAwsRequestId <> "/error" let body = Just $ Map.fromList [ ( "errorMessage", errMsg ) , ( "errorType", errType )@@ -199,5 +206,5 @@ where addTraceId req = req { HTTP.requestHeaders- = (traceIdHeader, C8.pack $ ct liTraceId) : HTTP.requestHeaders req+ = (traceIdHeader, C8.pack $ cts liTraceId) : HTTP.requestHeaders req }
src/AWS/Lambda/RuntimeAPI/Types.hs view
@@ -4,14 +4,12 @@ , LambdaExecutionContext(..) , MobileInvocationMetadata(..) , Text- , ct , module Control.DeepSeq , module Control.Exception.Safe , module Control.Monad , module Data.Aeson , module Data.Function , module Data.String- , module Data.Text.Conversions , module Data.Typeable , module Data.Word , module GHC.Generics@@ -23,7 +21,6 @@ import Data.Function ( (&) ) import Data.String ( fromString, IsString(..) ) import Data.Text (Text)-import Data.Text.Conversions ( ToText, FromText, convertText ) import Data.Typeable (typeOf) import Data.Word (Word64) import GHC.Generics@@ -32,10 +29,6 @@ import qualified Data.Char as Char import qualified Network.HTTP.Client as HTTP --- | Shorthand for 'convertText' from 'Data.Text.Conversions'-ct :: (ToText a, FromText b) => a -> b-ct = convertText- -- | Our implementation of how to map the field names to JSON labels modifyFieldLabel :: String -> String modifyFieldLabel str =@@ -62,7 +55,7 @@ data MobileInvocationMetadata = MobileInvocationMetadata { mimClientContext :: Text -- ^ the client's execution context , mimCognitoIdentity :: Text -- ^ the client's identity- } deriving (Eq, Generic, NFData)+ } deriving (Show, Eq, Generic, NFData) instance ToJSON MobileInvocationMetadata where toJSON = JSON.genericToJSON jsonOptions@@ -79,7 +72,7 @@ , liTraceId :: Text -- ^ The details about this AWS X-Ray trace , liMobileMetadata :: Maybe MobileInvocationMetadata -- ^ The mobile data if the Lambda was called from the AWS Mobile SDK , liPayload :: payload -- ^ The input to the Lambda- } deriving (Eq, Generic, ToJSON, FromJSON, Generic1, ToJSON1, FromJSON1)+ } deriving (Show, Eq, Generic, ToJSON, FromJSON, Generic1, ToJSON1, FromJSON1) instance (NFData payload) => NFData (LambdaInvocation payload) instance NFData1 LambdaInvocation@@ -93,7 +86,7 @@ = LambdaSuccess payload -- ^ Denotes success and provides the value to return | LambdaError ErrorInfo -- ^ Denotes failure and provides details | LambdaNop -- ^ Denotes that no invocation was provided- deriving (Eq, Generic, ToJSON, FromJSON, Generic1, ToJSON1, FromJSON1)+ deriving (Show, Eq, Generic, ToJSON, FromJSON, Generic1, ToJSON1, FromJSON1) instance (NFData payload) => NFData (LambdaResult payload) instance NFData1 LambdaResult