Hello. I'm working with a Clojure app that uses https://github.com/weavejester/integrant. We'd like to deploy it with Holy-Lambda but, based on the examples, it seems that Holy-Lambda expects a handler function? Is it possible to use Integrant/Mount system libraries when deploying with Holy Lambda?
A quick answer. Yes.
I'll write a longer answer in 2 hours. Just getting up from the 🛌.
;; EXAMPLE 1 - routes outside of the system
(defn AWSLambdaHandler [system request] {:body "Hello" :statusCode 200 :headers {})
(def system (atom nil))
(defn wrap-with-system [handler]
(fn [request]
(handler @system request)))
(defn start-system
[]
(reset! system (sys/start-system {:profile :prod
:base :lambda})))
(def AWSLambdaHandlerWrapped (wrap-with-system AWSLambdaHandler)
(h/entrypoint [#'AWSLambdaHandlerWrapped] {:init-hook start-system})
;; Example 2 - routes inside a system
(defn AWSLambdaHandler [system request] {:body "Hello" :statusCode 200 :headers {})
(defn match-handler-by-request [request] AWSLambdaHandler)
(def system (atom nil))
(defn wrap-with-system []
(fn [request]
((match-handler-by-request @system request) @system request)))
(defn start-system
[]
(reset! system (sys/start-system {:profile :prod
:base :lambda})))
(def UnifiedAWSLambdaWrapper (wrap-with-system))
(h/entrypoint [#'UnifiedAWSLambdaWrapper] {:init-hook start-system})Amazing! I will try this. Thank you!
You are very welcome! Thank you for asking this question.