Skip to content

Commit

Permalink
Release v0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
FieryCod committed Nov 1, 2021
1 parent 32e9436 commit bb78262
Show file tree
Hide file tree
Showing 32 changed files with 5,353 additions and 81 deletions.
2 changes: 1 addition & 1 deletion .nrepl-port
Original file line number Diff line number Diff line change
@@ -1 +1 @@
40963
40771
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# CHANGELOG

## 0.1.0
- Add support for async non-async handlers
- Support all Ring types
- Support all holy-lambda backends
- Support HttpAPI as Lambda Integration

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
- [HttpApi](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop.html#http-api-examples)
- Java Version >= 11
- GraalVM Native Image >= 21.2.0
- Holy Lambda >= 0.6.0
- Holy Lambda >= 0.6.0 [all backends: native, babashka, clojure]

## Usage
- **With plain [ring](https://github.com/ring-clojure/ring)**
Expand Down
18 changes: 7 additions & 11 deletions test/integration/bb.edn → examples/babashka/bb.edn
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
{:deps {io.github.FieryCod/holy-lambda-babashka-tasks
{:git/url "https://github.com/FieryCod/holy-lambda"
:deps/root "./modules/holy-lambda-babashka-tasks"
:sha "eb299bf6e380bcc8e484e80f8f16363bc5deb41c"}
io.github.FieryCod/holy-lambda {:mvn/version "0.6.1"}
io.github.FieryCod/holy-lambda-ring-adapter {:local/root "../../"}}

:paths ["src"]
{:deps {io.github.FieryCod/holy-lambda-babashka-tasks
{:git/url "https://github.com/FieryCod/holy-lambda"
:deps/root "./modules/holy-lambda-babashka-tasks"
:sha "e6c47274a2bfc7576a9da0ccdbc079c1e83bee17"}
io.github.FieryCod/holy-lambda-ring-adapter {:local/root "../../"}
io.github.FieryCod/holy-lambda {:mvn/version "0.6.2"}}

;; Minimal babashka version which should be used in conjuction with holy-lambda
:min-bb-version "0.3.7"

:holy-lambda/options {
;; User should use docker for local development and use `HL_NO_DOCKER` environment variable
;; set to "true" for CI based deployments.
;; For CI based deployments user should base it's builder image on `fierycod/graalvm-native-image:ce`
:docker {

;; Check https://docs.docker.com/network/
Expand Down Expand Up @@ -73,4 +68,5 @@
hl:compile holy-lambda.tasks/hl:compile
hl:doctor holy-lambda.tasks/hl:doctor
hl:clean holy-lambda.tasks/hl:clean
hl:update-bb-tasks holy-lambda.tasks/hl:update-bb-tasks
hl:version holy-lambda.tasks/hl:version}}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
(ns core
(:require
[handler :as handler]
[babashka.process :as p]
[fierycod.holy-lambda-ring-adapter.core :as hlra]
[fierycod.holy-lambda.core :as h]))

(defn- shell-no-exit
[cmd & args]
(p/process (into (p/tokenize cmd) (remove nil? args)) {:inherit true}))


(def HttpApiGatewayProxy (hlra/wrap-hl-req-res-model handler/router))

(h/entrypoint [#'HttpApiGatewayProxy])
32 changes: 32 additions & 0 deletions examples/babashka/src/handler.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
(ns handler
(:require
[clojure.string :as str]
[hiccup2.core :refer [html]]
[clojure.core.match :refer [match]]
[clojure.java.io :as io]))

(defn logo
[_request]
{:body (io/file "./logo.png")
:status 200
:headers {"content-type" "image/png"}})

(defn hello
[_request]
{:body {"hello" "world"}
:status 200
:headers {"content-type" "application/json"}})

(defn router
[req]
(let [paths (vec (rest (str/split (:uri req) #"/")))]
(match [(:request-method req) paths]
[:get ["logo"]] (handler/logo req)
[:get ["hello"]] (handler/hello req)
[:get ["welcome"]] {:body (str (html [:html "Welcome!"
[:img {:src "./logo"}]]))
:headers {"content-type" "text/html; charset=utf-8"}
:status 200}
:else {:body "Not Found"
:status 404}
)))
File renamed without changes.
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ Resources:
Type: AWS::Serverless::Function
Properties:
Runtime: provided.al2
Handler: core.ExampleLambda
Handler: core.HttpApiGatewayProxy
CodeUri: src
Layers:
- arn:aws:lambda:eu-central-1:443526418261:layer:holy-lambda-babashka-runtime-amd64:2
- arn:aws:lambda:eu-central-1:443526418261:layer:holy-lambda-babashka-runtime-amd64:3
- !Ref DependenciesLayer
# Architectures:
# - arm64
Expand Down
1 change: 1 addition & 0 deletions examples/native/.nrepl-port
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
42507
74 changes: 74 additions & 0 deletions examples/native/bb.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{:deps {io.github.FieryCod/holy-lambda-babashka-tasks
{:git/url "https://github.com/FieryCod/holy-lambda"
:deps/root "./modules/holy-lambda-babashka-tasks"
:sha "e6c47274a2bfc7576a9da0ccdbc079c1e83bee17"}
io.github.FieryCod/holy-lambda-ring-adapter {:local/root "../../"}
io.github.FieryCod/holy-lambda {:mvn/version "0.6.2"}}

;; Minimal babashka version which should be used in conjuction with holy-lambda
:min-bb-version "0.3.7"

:holy-lambda/options {
:docker {

;; Check https://docs.docker.com/network/
;; Network setting for future versions of HL will propagate to AWS SAM as well
;; Options: "host"|"bridge"|"overlay"|"none"|nil|"macvlan"
:network nil

;; HL runs some bb tasks in docker context. You can put additional resources to the context by using volumes.
;; ----------------------------------------------------------------------------
;; Single volume definition:
;;
;; {:docker "/where-to-mount-in-docker"
;; :host "relative-local-path"}
:volumes []

;; GraalVM Community holy-lambda compatible docker image
;; You can always build your own GraalVM image with enterprise edition
:image "ghcr.io/fierycod/holy-lambda-builder:amd64-java11-21.3.0"}

:build {:compile-cmd "clojure -X:uberjar-lambda"
;; Used when either :docker is nil or
;; `HL_NO_DOCKER` environment variable is set to "true"
;; Might be set via `GRAALVM_HOME` environment variable
:graalvm-home "~/.graalvm"}

:backend
{
;; Babashka pods should be shipped using AWS Lambda Layer
;; Check this template https://github.com/aws-samples/aws-lambda-layers-aws-sam-examples/blob/master/aws-sdk-layer/template.yaml
;; and official docs https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-layers.html
;; CodeUri should be `.holy-lambda/pods`
;; For now pods should be declared in `bb.edn`. See: https://github.com/babashka/babashka/issues/768#issuecomment-825016317
;;
;; `IMPORTANT:` 3rd party babashka compatible libraries should be distributed as a layers (CodeUri: .holy-lambda/bb-clj-deps)
:pods {}

;; For `:native` backend you can provide your own bootstrap file
:bootstrap-file "bootstrap"

;; For `:native` backend you can provide some native resources which will be available during lambda execution
;; Resources are packed as is.
;; :native-deps "resources"

;; Specify custom arguments for native image generation
;; Check https://www.graalvm.org/reference-manual/native-image/Options/
:native-image-args ["--verbose"
"--no-fallback"
"--report-unsupported-elements-at-runtime"
"-H:+AllowIncompleteClasspath"
"-H:IncludeResources=public/.*"
"--initialize-at-build-time=javax.xml.datatype,jdk.xml.internal"
"--no-server"]}}

:tasks {:requires ([holy-lambda.tasks])
hl:docker:run holy-lambda.tasks/hl:docker:run
hl:native:conf holy-lambda.tasks/hl:native:conf
hl:native:executable holy-lambda.tasks/hl:native:executable
hl:babashka:sync holy-lambda.tasks/hl:babashka:sync
hl:compile holy-lambda.tasks/hl:compile
hl:doctor holy-lambda.tasks/hl:doctor
hl:clean holy-lambda.tasks/hl:clean
hl:update-bb-tasks holy-lambda.tasks/hl:update-bb-tasks
hl:version holy-lambda.tasks/hl:version}}
34 changes: 34 additions & 0 deletions examples/native/deps.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{:deps {org.clojure/clojure {:mvn/version "1.10.3"}
com.github.clj-easy/graal-build-time {:mvn/version "0.1.4"}
io.github.FieryCod/holy-lambda {:mvn/version "0.6.2"}
io.github.FieryCod/holy-lambda-ring-adapter {:local/root "../../"}
ring/ring {:mvn/version "1.9.4"}
metosin/muuntaja {:mvn/version "0.6.8"}
metosin/malli {:mvn/version "0.6.2"}
metosin/reitit-core {:mvn/version "0.5.15"}
metosin/reitit-middleware {:mvn/version "0.5.15"}
metosin/reitit-malli {:mvn/version "0.5.15"}
metosin/reitit-ring {:mvn/version "0.5.15"}
metosin/reitit-swagger {:mvn/version "0.5.15"}
com.stuartsierra/component {:mvn/version "1.0.0"}
metosin/reitit-swagger-ui {:mvn/version "0.5.15"
:exclusions [metosin/ring-swagger-ui]}
metosin/ring-swagger-ui {:mvn/version "3.46.0-1"}}

:paths ["src" "resources"]

:aliases {:uberjar-lambda {:replace-deps {com.github.seancorfield/depstar {:mvn/version "2.1.303"}}
:exec-fn hf.depstar/uberjar
:exec-args {:aot ["example.lambda"]
:main-class "example.lambda"
:jar ".holy-lambda/build/output.jar"
:jvm-opts ["-Dclojure.compiler.direct-linking=true"
"-Dclojure.spec.skip-macros=true"]}}
:uberjar-server {:replace-deps {com.github.seancorfield/depstar {:mvn/version "2.1.303"}}
:exec-fn hf.depstar/uberjar
:exec-args {:aot ["example.server"]
:main-class "example.server"
:jar ".holy-lambda/build/output.jar"
:jvm-opts ["-Dclojure.compiler.direct-linking=true"
"-Dclojure.spec.skip-macros=true"]}}
}}
20 changes: 20 additions & 0 deletions examples/native/resources/native-configuration/jni-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
{
"name":"example.lambda",
"methods":[{"name":"main","parameterTypes":["java.lang.String[]"] }]}
,
{
"name":"java.lang.ClassLoader",
"methods":[
{"name":"getPlatformClassLoader","parameterTypes":[] },
{"name":"loadClass","parameterTypes":["java.lang.String"] }
]}
,
{
"name":"jdk.internal.loader.ClassLoaders$PlatformClassLoader"}
,
{
"name":"org.graalvm.nativebridge.jni.JNIExceptionWrapperEntryPoints",
"methods":[{"name":"getClassName","parameterTypes":["java.lang.Class"] }]}

]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{
"type":"agent-extracted",
"classes":[
]
}
]

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[
]
104 changes: 104 additions & 0 deletions examples/native/resources/native-configuration/reflect-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
[ {
"name" : "[B"
}, {
"name" : "[C"
}, {
"name" : "[D"
}, {
"name" : "[F"
}, {
"name" : "[I"
}, {
"name" : "[J"
}, {
"name" : "[Lcom.fasterxml.jackson.databind.deser.Deserializers;"
}, {
"name" : "[Lcom.fasterxml.jackson.databind.deser.KeyDeserializers;"
}, {
"name" : "[Lcom.fasterxml.jackson.databind.deser.ValueInstantiators;"
}, {
"name" : "[Lcom.fasterxml.jackson.databind.ser.Serializers;"
}, {
"name" : "[Ljava.lang.Object;"
}, {
"name" : "[Lreitit.Trie$Matcher;"
}, {
"name" : "[S"
}, {
"name" : "[Z"
}, {
"name" : "com.fasterxml.jackson.databind.ext.Java7SupportImpl",
"methods" : [ {
"name" : "<init>",
"parameterTypes" : [ ]
} ]
},
{ "name": "org.msgpack.template.builder.JavassistTemplateBuilder",
"allPublicMethods": true,
"allPublicConstructors": true
},
{
"name" : "java.io.OutputStream",
"queryAllPublicMethods" : true
}, {
"name" : "java.io.Serializable",
"queryAllDeclaredMethods" : true
}, {
"name" : "java.lang.Class",
"queryAllPublicMethods" : true
}, {
"name" : "java.lang.Iterable",
"queryAllDeclaredMethods" : true
}, {
"name" : "java.lang.Object",
"queryAllPublicMethods" : true
}, {
"name" : "java.lang.Runnable",
"queryAllDeclaredMethods" : true
}, {
"name" : "java.lang.String",
"queryAllPublicMethods" : true,
"methods" : [ {
"name" : "contains",
"parameterTypes" : [ "java.lang.CharSequence" ]
} ]
}, {
"name" : "java.lang.reflect.AccessibleObject",
"methods" : [ {
"name" : "canAccess",
"parameterTypes" : [ "java.lang.Object" ]
} ]
}, {
"name" : "java.security.MessageDigestSpi"
}, {
"name" : "java.security.SecureRandomParameters"
}, {
"name" : "java.util.Map",
"queryAllDeclaredMethods" : true
}, {
"name" : "java.util.Properties",
"queryAllPublicMethods" : true,
"methods" : [ {
"name" : "getProperty",
"parameterTypes" : [ "java.lang.String" ]
} ]
}, {
"name" : "java.util.concurrent.Callable",
"queryAllDeclaredMethods" : true
}, {
"name" : "muuntaja.protocols.StreamableResponse",
"allPublicFields" : true,
"queryAllPublicMethods" : true
}, {
"name" : "sun.security.provider.NativePRNG",
"methods" : [ {
"name" : "<init>",
"parameterTypes" : [ ]
} ]
}, {
"name" : "sun.security.provider.SHA",
"methods" : [ {
"name" : "<init>",
"parameterTypes" : [ ]
} ]
} ]
Loading

0 comments on commit bb78262

Please sign in to comment.