Name: functionless
Owner: Tweag I/O
Description: CLI tool for packaging Haskell executables for AWS Lambda
Created: 2017-02-01 15:17:25.0
Updated: 2018-05-15 19:44:13.0
Pushed: 2017-06-02 14:49:25.0
Size: 156
Language: Java
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Functionless is a tool that allows you to use Haskell functions as lamba
s on
AWS Lambda.
It provides:
.jar
executable on AWS lambdamakeAwsLambdaHandler
that creates the appropriate JNI bindings and FFI..jar
local executable that uses stdin
and stdout
for local testing.functionless
requires a few things from your build options:
c-options: -dynamic -threaded -Wall
-options: -pie
functionless
and bytestring
in its
build-depends
.Your lambda handler will have the following type:
Handler :: a -> BS.ByteString -> IO BS.ByteString
The a
here is for the Context
of AWS Lambda, which is not currently
supported by functionless
, but will be if users express such a need.
Inputs and outputs are in the form of ByteString
s because we use the
stream API
of AWS Lambda.
Users will thus have to deserialize their input and serialize their output.
The last part is to use the Functionless.TH.makeAwsLambdaHandler
template
Haskell function on your handler function like this:
AwsLambdaHandler 'realHandler
This is used to do the proper type conversions from Java, and generate the appropriate JNI bindings for your function to be found.
In order to package your program into a usable .jar
, simply call
functionless
on your executable target:
k --nix exec -- functionless your-exe
One of the reasons you needed an executable is for easily finding your
binary, this is used by functionless
in order to find the package.
The previous command will generate the your-exe.jar
, .jar
that you can
then upload on the AWS console.
functionless
also provides an easy way to test locally.
If you launch your executable on your machine using:
-jar your-exe.jar
Your handler, will be called on your machine and will use stdin
as its
input stream, and stdout
as is output stream. This avoids going back
and forth to the AWS console to test your program.
Context
mentionned
above.-pie
in ld-options
HaskellLibraryLoader
to maven, so that we
don't copy it from jarify
.