Skip to content

Commit 0d34c17

Browse files
feat(example, runtime, version): Add sqs example & bump the version of Clojure dependency
1 parent acaf400 commit 0d34c17

File tree

18 files changed

+311
-19
lines changed

18 files changed

+311
-19
lines changed

examples/hello-lambda/Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,17 @@ dry-api:
2626

2727
native-compile:
2828
@rm -Rf latest.zip
29-
@fnative "-jar target/hello-lambda.jar --report-unsupported-elements-at-runtime --no-fallback --enable-url-protocols=http,https --no-server -J-Xmx3G -J-Xms3G --initialize-at-build-time"
29+
@fnative "-jar target/hello-lambda.jar \
30+
--report-unsupported-elements-at-runtime \
31+
--no-fallback \
32+
--enable-url-protocols=http,https \
33+
--no-server -J-Xmx3G -J-Xms3G \
34+
--initialize-at-build-time"
3035
@mv -f hello-lambda bootstrap
3136
@zip latest bootstrap
3237

3338
native-dry-api:
34-
@sam local start-api --template ./native-template.yml
39+
@sam local start-api --template ./native-template.yml --skip-pull-image
3540

3641
pack:
3742
@sam package --template-file ./template.yml --output-template-file packaged.yaml --s3-bucket $(BUCKET_NAME) --s3-prefix "hello-lambda-latest"

examples/hello-lambda/native-template.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
AWSTemplateFormatVersion: '2010-09-09'
22
Transform: AWS::Serverless-2016-10-31
33
Description: >
4-
Example basic lambda using `holy-lambda` micro library
4+
Example hello lambda using `holy-lambda` micro library
55
66
Parameters:
77
Runtime:
88
Type: String
99
Default: provided
1010
Timeout:
1111
Type: Number
12-
Default: 40
12+
Default: 10
1313
MemorySize:
1414
Type: Number
1515
Default: 2000
@@ -31,7 +31,7 @@ Resources:
3131
Handler: hello-lambda.core.HelloLambda
3232
FunctionName: HelloLambdaFunction
3333
Events:
34-
HelloLambda:
34+
HelloEvent:
3535
Type: Api
3636
Properties:
3737
Path: /
@@ -43,7 +43,7 @@ Resources:
4343
Handler: hello-lambda.core.ByeLambda
4444
FunctionName: ByeLambdaFunction
4545
Events:
46-
HelloLambda:
46+
ByeEvent:
4747
Type: Api
4848
Properties:
4949
Path: /bye

examples/hello-lambda/project.clj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
(defproject hello-lambda "0.1.0-SNAPSHOT"
2-
:dependencies [[org.clojure/clojure "1.9.0"]
3-
[fierycod/holy-lambda "0.0.1"]]
2+
:dependencies [[org.clojure/clojure "1.10.1-RC1"]
3+
[fierycod/holy-lambda "0.0.2"]]
4+
:global-vars {*warn-on-reflection* true}
45
:main ^:skip-aot hello-lambda.core
56
:profiles {:uberjar {:aot :all}}
67
:uberjar-name "hello-lambda.jar")

examples/hello-lambda/reflect.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[{
2+
"name" : "org.apache.commons.logging.impl.Jdk14Logger",
3+
"allDeclaredConstructors" : true,
4+
"allPublicConstructors" : true,
5+
"allDeclaredMethods" : true,
6+
"allPublicMethods" : true
7+
}]

examples/hello-lambda/template.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Resources:
3131
Handler: hello-lambda.core.HelloLambda
3232
FunctionName: HelloLambdaFunction
3333
Events:
34-
HelloLambda:
34+
HelloEvent:
3535
Type: Api
3636
Properties:
3737
Path: /
@@ -43,7 +43,7 @@ Resources:
4343
Handler: hello-lambda.core.ByeLambda
4444
FunctionName: ByeLambdaFunction
4545
Events:
46-
HelloLambda:
46+
ByeEvent:
4747
Type: Api
4848
Properties:
4949
Path: /bye

examples/sqs-example/.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/target
2+
/classes
3+
/checkouts
4+
profiles.clj
5+
pom.xml
6+
dependencies/**
7+
pom.xml.asc
8+
*.jar
9+
*.class
10+
/.lein-*
11+
/.nrepl-port
12+
.hgignore
13+
.hg/

examples/sqs-example/Makefile

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
SHELL := /bin/bash
2+
GREEN='\033[0;32m'
3+
YELLOW='\033[1;33m'
4+
NC='\033[0m'
5+
6+
.PHONY: install-holy-lambda native-dry-run compile dry-run native-compile native-pack native-deploy native-destroy logs-tail
7+
BUCKET_NAME=holy-lambda--sqs-example
8+
STACK_NAME=holy-lambda--sqs-example
9+
APP_REGION=eu-central-1
10+
LAMBDA_NAME=ReceiveStringLambdaFunction
11+
EVENT_PAYLOAD_FILE=./sample-receive-event.json
12+
13+
prepare-dependencies:
14+
@cp /usr/lib/jvm/java-1.8.0-openjdk/jre/lib/amd64/libsunec.so ./dependencies/
15+
16+
make-bucket:
17+
@aws s3 mb s3://$(BUCKET_NAME)
18+
19+
destroy-bucket:
20+
@aws s3 rb s3://$(BUCKET_NAME) --force --region $(APP_REGION)
21+
22+
install-holy-lambda:
23+
@bash -c "cd ../../ && lein install"
24+
25+
compile:
26+
@lein uberjar
27+
28+
dry-api:
29+
@sam local start-api --skip-pull-image
30+
31+
native-compile:
32+
@rm -Rf latest.zip
33+
@fnative "-jar target/sqs-example.jar \
34+
--report-unsupported-elements-at-runtime \
35+
--no-fallback \
36+
--enable-url-protocols=http,https \
37+
--no-server -J-Xmx3G -J-Xms3G \
38+
--initialize-at-build-time \
39+
-H:+PrintClassInitialization \
40+
--enable-all-security-services \
41+
-H:ReflectionConfigurationFiles=reflect.json \
42+
-H:DynamicProxyConfigurationFiles=dynamic-proxies.json"
43+
@mv -f sqs-example bootstrap
44+
@zip -j latest bootstrap dependencies/libsunec.so
45+
46+
native-dry-api:
47+
@sam local start-api --template ./native-template.yml --skip-pull-image
48+
49+
native-sqs-invoke:
50+
@sam local invoke $(LAMBDA_NAME) --template ./native-template.yml --skip-pull-image -e $(EVENT_PAYLOAD_FILE)
51+
52+
sqs-invoke:
53+
@sam local invoke $(LAMBDA_NAME) --template ./template.yml --skip-pull-image -e $(EVENT_PAYLOAD_FILE)
54+
55+
pack:
56+
@sam package --template-file ./template.yml --output-template-file packaged.yaml --s3-bucket $(BUCKET_NAME) --s3-prefix "sqs-example-latest"
57+
58+
deploy:
59+
@sam deploy --template-file ./packaged.yaml --stack-name $(STACK_NAME) --capabilities CAPABILITY_IAM --region $(APP_REGION)
60+
61+
native-pack:
62+
@sam package --template-file ./native-template.yml --output-template-file native-packaged.yaml --s3-bucket $(BUCKET_NAME) --s3-prefix "sqs-example-latest"
63+
64+
native-deploy:
65+
@sam deploy --template-file ./native-packaged.yaml --stack-name $(STACK_NAME) --capabilities CAPABILITY_IAM --region $(APP_REGION)
66+
67+
native-destroy:
68+
@aws cloudformation delete-stack --stack-name $(STACK_NAME) --region $(APP_REGION)
69+
70+
logs-tail:
71+
sam logs -n $(LAMBDA_NAME) --stack-name $(STACK_NAME) -t

examples/sqs-example/dependencies/.gitkeep

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[
2+
["org.apache.http.conn.HttpClientConnectionManager", "org.apache.http.pool.ConnPoolControl", "com.amazonaws.http.conn.Wrapped"]
3+
]
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
AWSTemplateFormatVersion: '2010-09-09'
2+
Transform: AWS::Serverless-2016-10-31
3+
Description: >
4+
Example sqs lambda using `holy-lambda` micro library
5+
6+
Parameters:
7+
Runtime:
8+
Type: String
9+
Default: provided
10+
Timeout:
11+
Type: Number
12+
Default: 10
13+
MemorySize:
14+
Type: Number
15+
Default: 2000
16+
CodeUri:
17+
Type: String
18+
Default: latest.zip
19+
20+
Globals:
21+
Function:
22+
Runtime: !Ref Runtime
23+
Timeout: !Ref Timeout
24+
MemorySize: !Ref MemorySize
25+
CodeUri: !Ref CodeUri
26+
27+
Resources:
28+
BaseStringSQS:
29+
Type: AWS::SQS::Queue
30+
Properties:
31+
DelaySeconds: 1
32+
33+
ConcatenatedHolySQS:
34+
Type: AWS::SQS::Queue
35+
Properties:
36+
DelaySeconds: 1
37+
38+
ReceiveStringLambdaFunction:
39+
Type: AWS::Serverless::Function
40+
Properties:
41+
Handler: sqs-example.core.ReceiveStringLambda
42+
FunctionName: ReceiveStringLambdaFunction
43+
Events:
44+
ReceiveStringEvent:
45+
Type: SQS
46+
Properties:
47+
Queue: !GetAtt BaseStringSQS.Arn
48+
BatchSize: 1
49+
Policies:
50+
- SQSSendMessagePolicy:
51+
QueueName:
52+
!GetAtt ConcatenatedHolySQS.QueueName
53+
Environment:
54+
Variables:
55+
CONCATENATED_HOLY_SQS_URL: !Ref ConcatenatedHolySQS

0 commit comments

Comments
 (0)