-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Haskell on AWS Lambda Runtime API -- -- Make "native" Haskell AWS Lambda (using Runtime API). -- -- @package aws-lambda-runtime @version 0.0.0.1 -- | Based on the logic as implemented in -- https://github.com/awslabs/aws-lambda-cpp module AWS.Lambda.RuntimeAPI -- | Default main to implement AWS Lambda using Runtime API defaultMain :: (Request -> IO Response) -> IO () -- | Like defaultMain but work with JSON jsonMain :: (FromJSON a, ToJSON b) => (GenRequest a -> IO b) -> IO () -- | Check the existence of AWS_LAMBDA_RUNTIME_API environment -- variable. -- -- If it exists, assume we are running in AWS Lambda environment, i.e. -- run normally. Otherwise use supplied MockOptions autoMockMain :: Mock -> (Request -> IO Response) -> IO () -- | Like autoMockMain but works with JSON autoMockJsonMain :: (FromJSON a, ToJSON b) => GenMock a -> (GenRequest a -> IO b) -> IO () type Mock = GenMock ByteString -- | How to mock the Request, what to do with the Response. data GenMock a Mock :: IO (GenRequest a) -> (Response -> IO ()) -> GenMock a [mockRequest] :: GenMock a -> IO (GenRequest a) [mockResponse] :: GenMock a -> Response -> IO () -- | Create Mock request makeMockRequest :: a -> Int64 -> IO (GenRequest a) -- | Request with ByteString payload type Request = GenRequest ByteString data Response SuccessResponse :: !MediaType -> !ByteString -> Response -- | error type, error message FailureResponse :: !Text -> !Text -> Response data GenRequest a Request :: !a -> !RequestId -> !ByteString -> !ByteString -> !ByteString -> !ByteString -> !Deadline -> GenRequest a -- | The user's payload represented (originally) as a UTF-8 string. [requestPayload] :: GenRequest a -> !a -- | And identifier unique to the current invocation. [requestId] :: GenRequest a -> !RequestId -- | X-Ray tracigng of the current invocation. [requestXRayTraceId] :: GenRequest a -> !ByteString -- | Information about the client application and device when invoked -- through the AWS Mobile SDK. [requestClientContext] :: GenRequest a -> !ByteString -- | Information about the Amazon Cognito identity provider when invoked -- through the AWS Mobile SDK. [requestCognitoIdentity] :: GenRequest a -> !ByteString -- | The ARN requested. This can be different in each invoke that executes -- the same version. [requestARN] :: GenRequest a -> !ByteString -- | Function execution deadline counted in milliseconds since the Unix -- epoch. [requestDeadline] :: GenRequest a -> !Deadline -- | Opaque request id data RequestId -- | Get time remaining (milliseconds). getTimeRemaining :: GenRequest a -> IO Int64 -- | Create JSON response. jsonResponse :: ToJSON a => a -> Response jsonMediaType :: MediaType instance GHC.Show.Show AWS.Lambda.RuntimeAPI.Response instance Data.Traversable.Traversable AWS.Lambda.RuntimeAPI.GenRequest instance Data.Foldable.Foldable AWS.Lambda.RuntimeAPI.GenRequest instance GHC.Base.Functor AWS.Lambda.RuntimeAPI.GenRequest instance GHC.Show.Show a => GHC.Show.Show (AWS.Lambda.RuntimeAPI.GenRequest a) instance GHC.Show.Show AWS.Lambda.RuntimeAPI.Deadline instance GHC.Show.Show AWS.Lambda.RuntimeAPI.RequestId instance Control.DeepSeq.NFData AWS.Lambda.RuntimeAPI.HttpRes instance Control.DeepSeq.NFData AWS.Lambda.RuntimeAPI.Response -- | Utility to package lambda -- -- Example usage, you need to run it on AWS Linux (e.g. Docker, see -- Dockerfile) with GHC, cabal and -- cabal-plan available. -- --
--   module Main (main) where
--   
--   import AWS.Lambda.RuntimeAPI.Package (defaultConf, packageAwsLambda)
--   import Data.Char                     (isSpace)
--   
--   import qualified Data.ByteString.Lazy as LBS
--   import qualified System.Process       as P
--   
--   main :: IO ()
--   main = do
--       -- Build the executable
--       let exe = "example-lambda"
--       P.callProcess "cabal" ["new-build", exe]
--   
--       -- Find the build artifact
--       exePath <- trim <$> P.readProcess "cabal-plan" [ "list-bin", exe ] ""
--       putStrLn $ "Packaging executable: " ++ exePath
--   
--       -- Package it
--       zipFile <- packageAwsLambda defaultConf exePath
--       LBS.writeFile "example-lambda.zip" zipFile
--     where
--       trim = dropWhile isSpace . reverse . dropWhile isSpace . reverse
--   
-- -- Given such environment, we can build an example lambda function: -- --
--   % docker run -ti --rm -v $(pwd):work -w work amazonlinux-with-ghc
--   
--   % cabal new-update
--   % cabal new-build
--   % runghc package-example-lambda.hs
--   
-- -- The resulting example-lambda.zip is ready to be uploaded! module AWS.Lambda.RuntimeAPI.Package -- | Package AWS Lambda executable. packageAwsLambda :: Conf -> FilePath -> IO ByteString data Conf Conf :: ![String] -> !FilePath -> IO ByteString -> Conf -- | library names we know surely need to be packaged [_confAdditionalLibs] :: Conf -> ![String] -- | function to read file from filesystem [_confReadFile] :: Conf -> !FilePath -> IO ByteString defaultConf :: Conf confAdditionalLibs :: Functor f => ([String] -> f [String]) -> Conf -> f Conf confReadFile :: Functor f => ((FilePath -> IO ByteString) -> f (FilePath -> IO ByteString)) -> Conf -> f Conf -- | Run ldd on given filepath, return .so -- files. findExtraLibs :: [String] -> FilePath -> IO [FilePath]