File tree Expand file tree Collapse file tree 3 files changed +43
-0
lines changed
Expand file tree Collapse file tree 3 files changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ .DS_Store
2+ .vscode
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments