portkey

Portkey: from REPL to Serverless in one call
cgrand 2017-04-28T12:31:01.681944Z

Ok so I have made a decision between .jar or .zip

cgrand 2017-04-28T12:31:22.689139Z

.zip because it allows embedding deps as is (no need to unpack and repack or to have a clustom classloader)

cgrand 2017-04-28T12:37:31.812372Z

for those new to the project: it’s not working yet.

cgrand 2017-04-28T12:38:12.826290Z

what’s working: serialization/deserialization of the lambda and computation of the deps

cgrand 2017-04-28T12:39:25.851592Z

For example serializing

(def stub
   (reify com.amazonaws.services.lambda.runtime.RequestStreamHandler
     (handleRequest [_ in out ctx]
       (prn in out ctx))))
computes that only 4 interfaces are needed out of the AWS sdk so only these classes will be sent

1
cgrand 2017-04-28T14:15:16.431215Z

I haven’t tested yet (alpha testers welcome!) but portkey now produces things resembling a deployment package:

cgrand 2017-04-28T14:15:35.441121Z

Clojure 1.9.0-alpha15
user=> (require ‘[portkey.core :as pk])
Preparing for self instrumentation.
Ouroboros succesfully eating its own tail!
Instrumenting clojure.lang.Var... done!
nil
user=> (pk/package! “prn.zip” prn)
“prn.zip”

cgrand 2017-04-28T14:15:57.452287Z

and

$ ls -lh prn.zip
-rw-r--r--  1 christophe  staff   4,5M 28 avr 16:12 prn.zip

cgrand 2017-04-28T14:17:04.488123Z

(clojure alone is 4.1M)

cgrand 2017-04-28T14:17:59.517085Z

and

$ unzip -t prn.zip Archive:  prn.zip
    testing: bootstrap.kryo           OK
    testing: com/                     OK
    testing: com/amazonaws/           OK
    testing: com/amazonaws/services/   OK
    testing: com/amazonaws/services/lambda/   OK
    testing: com/amazonaws/services/lambda/runtime/   OK
    testing: com/amazonaws/services/lambda/runtime/Client.class   OK
    testing: com/amazonaws/services/lambda/runtime/ClientContext.class   OK
    testing: com/amazonaws/services/lambda/runtime/CognitoIdentity.class   OK
    testing: com/amazonaws/services/lambda/runtime/Context.class   OK
    testing: com/amazonaws/services/lambda/runtime/LambdaLogger.class   OK
    testing: com/amazonaws/services/lambda/runtime/RequestStreamHandler.class   OK
    testing: lib/                     OK
    testing: lib/asm-5.0.3.jar        OK
    testing: lib/carbonite-1.4.0.jar   OK
    testing: lib/chill-java-0.3.5.jar   OK
    testing: lib/clojure-1.9.0-alpha15.jar   OK
    testing: lib/kryo-2.21.jar        OK
    testing: lib/kryo-3.0.3.jar       OK
    testing: lib/minlog-1.2.jar       OK
    testing: lib/minlog-1.3.0.jar     OK
    testing: lib/objenesis-2.1.jar    OK
    testing: lib/reflectasm-1.07-shaded.jar   OK
    testing: lib/reflectasm-1.10.1.jar   OK
    testing: portkey/                 OK
    testing: portkey/LambdaStub.class   OK
    testing: portkey/SerializerStub.class   OK
    testing: portkey/kryo.clj         OK
    testing: portkey/logdep.clj       OK
No errors detected in compressed data of prn.zip.

cgrand 2017-04-28T14:21:17.622833Z

oh and btw (pk/package! "prn.zip" prn) makes no sense for a real lambda

cgrand 2017-04-28T14:42:00.297184Z

doc:

user=> (doc pk/package!)
-------------------------
portkey.core/package!
([out f])
  Writes f as AWS Lambda deployment packge to out.
   f must be a function of 3 arguments: input, output and context. (See RequestHandler)