Skip to content

Commit b9cb425

Browse files
author
Graham Krizek
committed
Initial Testing
1 parent 4343773 commit b9cb425

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.DS_Store
2+
.vscode

bootstrap

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/sh
2+
3+
set -euo pipefail
4+
5+
RUNTIME_PATH="2018-06-01/runtime"
6+
7+
sendInitError () {
8+
ERROR_MESSAGE=$1
9+
ERROR_TYPE=$2
10+
ERROR="{\"errorMessage\" : \"$ERROR_MESSAGE\", \"errorType\" : \"$ERROR_TYPE\"}"
11+
curl -X POST -d "$ERROR" "http://${AWS_LAMBDA_RUNTIME_API}/${RUNTIME_PATH}/invocation/$REQUEST_ID/error" > /dev/null
12+
echo "ERROR" >&2
13+
exit 1
14+
}
15+
16+
# Initialization
17+
source $LAMBDA_TASK_ROOT/"$(echo $_HANDLER | cut -d. -f1).sh"
18+
if [[ $? -ne 0 ]]; then
19+
sendInitError "Handler Not Found" "InvalidHandlerException"
20+
fi
21+
22+
# Processing
23+
while true
24+
do
25+
HEADERS="$(mktemp)"
26+
EVENT_DATA=$(curl -sS -LD "$HEADERS" -X GET "http://${AWS_LAMBDA_RUNTIME_API}/${RUNTIME_PATH}/invocation/next")
27+
REQUEST_ID=$(grep -Fi Lambda-Runtime-Aws-Request-Id "$HEADERS" | tr -d '[:space:]' | cut -d: -f2)
28+
RESPONSE=$($(echo "$_HANDLER" | cut -d. -f2) "$EVENT_DATA")
29+
echo $?
30+
echo "RESPONSE::::"
31+
curl -sS -X POST -d "$RESPONSE" "http://${AWS_LAMBDA_RUNTIME_API}/${RUNTIME_PATH}/invocation/${REQUEST_ID}/response" > /dev/null
32+
done

test.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
function handler () {
4+
EVENT_DATA=$1
5+
6+
echo "this is my function" >&2
7+
8+
echo $EVENT_DATA
9+
}

0 commit comments

Comments
 (0)