Skip to content

Commit 77a55ab

Browse files
committed
Remove unnecessary check for the existence of iid
1 parent daecb91 commit 77a55ab

File tree

2 files changed

+24
-27
lines changed

2 files changed

+24
-27
lines changed

src/fierycod/holy_lambda/core.cljc

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,27 +47,29 @@
4747
"
4848
{:added "0.0.1"}
4949
[lambdas & [{:keys [init-hook disable-analytics?]
50-
:or {init-hook (fn [] nil)
51-
disable-analytics? false}}]]
50+
:or {init-hook (fn [] nil)
51+
disable-analytics? false}}]]
5252
`(do
5353
(def ~'PRVL_ROUTES (into {} (mapv (fn [l#] [(str (str (:ns (meta l#)) "." (str (:name (meta l#))))) l#]) ~lambdas)))
5454
(defn ~'-main [& attrs#]
55+
(let [runtime-api-url# (System/getenv "AWS_LAMBDA_RUNTIME_API")
56+
handler-name# (or (first attrs#) (System/getenv "_HANDLER"))]
5557

56-
;; Side effect init-hook
57-
(~init-hook)
58+
;; Side effect init-hook
59+
(~init-hook)
5860

59-
;; executor = native-agent -- Indicates that the configuration for compiling via `native-image`
60-
;; will be generated via the agent.
61-
;;
62-
;; executor = anything else -- Run provided runtime loop
63-
(if (= (System/getProperty "executor") @#'fierycod.holy-lambda.agent/AGENT_EXECUTOR)
64-
;; Generate the native configuration for the lambdas
65-
(#'fierycod.holy-lambda.agent/routes->reflective-call! ~'PRVL_ROUTES)
61+
;; executor = native-agent -- Indicates that the configuration for compiling via `native-image`
62+
;; will be generated via the agent.
63+
;;
64+
;; executor = anything else -- Run provided runtime loop
65+
(if (= (System/getProperty "executor") @#'fierycod.holy-lambda.agent/AGENT_EXECUTOR)
66+
;; Generate the native configuration for the lambdas
67+
(#'fierycod.holy-lambda.agent/routes->reflective-call! ~'PRVL_ROUTES)
6668

67-
;; Start custom runtime loop
68-
(while true
69-
(#'fierycod.holy-lambda.custom-runtime/next-iter
70-
(System/getenv "AWS_LAMBDA_RUNTIME_API")
71-
(or (first attrs#) (System/getenv "_HANDLER"))
72-
~'PRVL_ROUTES
73-
~disable-analytics?))))))
69+
;; Start custom runtime loop
70+
(while true
71+
(#'fierycod.holy-lambda.custom-runtime/next-iter
72+
runtime-api-url#
73+
handler-name#
74+
~'PRVL_ROUTES
75+
~disable-analytics?)))))))

src/fierycod/holy_lambda/custom_runtime.clj

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@
3131
(let [response (u/http "POST" (url runtime iid "/error")
3232
{:statusCode 500
3333
:headers {"content-type" "application/json"}
34-
:body {:runtime-error true
35-
:err (Throwable->map err)}}
34+
:body (Throwable->map err)}
3635
disable-analytics?)]
3736
(when-not (response :success?)
38-
(u/println-err! (u/->str "[holy-lambda] Runtime error failed sent to AWS.\n" (str (response :body))))
37+
(u/println-err! (u/->str "[holy-lambda] Runtime error sent failed.\n" (str (response :body))))
3938
(System/exit 1))))
4039

4140
(defn- send-response
@@ -74,16 +73,12 @@
7473
(send-runtime-error runtime iid (u/->ex "Handler " ^String handler-name " not found!") disable-analitics?)
7574
(System/exit 1))
7675

77-
(when-not iid
78-
(send-runtime-error runtime iid (u/->ex "Failed to determine new invocation-id") disable-analitics?)
79-
(System/exit 1))
80-
81-
(when (and iid (aws-event :success?))
76+
(when (aws-event :success?)
8277
(try
8378
(send-response runtime
8479
iid
8580
(handler {:event (normalize-event event)
86-
:ctx (->aws-context iid headers event)})
81+
:ctx (->aws-context iid headers event)})
8782
disable-analitics?)
8883
(catch Exception err
8984
(send-runtime-error runtime iid err disable-analitics?))))))

0 commit comments

Comments
 (0)