Ok so I have made a decision between .jar
or .zip
.zip
because it allows embedding deps as is (no need to unpack and repack or to have a clustom classloader)
the code is here https://github.com/cgrand/portkey/blob/master/src/main/clojure/portkey/core.clj#L143
for those new to the project: it’s not working yet.
what’s working: serialization/deserialization of the lambda and computation of the deps
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 sentI haven’t tested yet (alpha testers welcome!) but portkey now produces things resembling a deployment package:
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”
and
$ ls -lh prn.zip
-rw-r--r-- 1 christophe staff 4,5M 28 avr 16:12 prn.zip
(clojure alone is 4.1M)
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.
oh and btw (pk/package! "prn.zip" prn)
makes no sense for a real lambda
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)