This repository has been archived by the owner on Apr 20, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
eulalie.lambda.util
Moe Aboulkheir edited this page Jul 14, 2016
·
7 revisions
Convenience functions for performing common
Lambda operations. If consuming
the library from Clojure/JVM, there are double-bang !!
/synchronous versions of
all of these functions available.
(invoke! creds fn-name type payload
& [{:keys [client-context log-type qualifier]}
{:keys [chan close?] :or {close? true}}])
- Returns a channel containing a single variant
[:ok result]
or[:error {:keys [type message]}]
- This applies only to application-level error conditions. In the event of service-level errors (invalid function name, etc.), the channel will contain an
ex-info
object - i.e. an Exception/Error, with an associated map having:type
&:message
keys. -
type
is one of:event
,:request-response
or:dry-run
-
payload
&client-context
are arbitrary EDN, which'll be transformed into JSON - Optional
:qualifier
identifies function version or alias -
log-type
one of:none
,:tail
- If
:tail
, the variant will have a metadata key:log-result
(invoke! creds :dog-bark :request-response {:name "Everyone"})
;; => [:ok "I'm barking at: Everyone"]
(invoke! creds :dog-bark :dry-run {:name "Everyone"})
;; => [:ok ""]
(invoke! creds :dog-bark :request-response {:name "Postman"})
;; => [:error {:type :handled
;; :message "I'm sorry, I don't really want to bark at you"}]
(request! creds fn-name payload
& [{:keys [client-context log-type qualifier]}
{:keys [chan close?] :or {close? true}}])
- Identical to
invoke!
, but assumes an invocation type of:request-response
(request! creds :dog-bark {:name "Postman"})
;; => [:error {:type :handled
;; :message "I'm sorry, I don't really want to bark at you"}]
(get-function! creds fn-name & [{:keys [chan close?] or {close? true}}])
{:code
{:location "https://..." :repository-type "S3"}
:configuration
{:role "arn:aws:iam::151963828411:role/lambda_basic_execution"
:description ""
:code-size 753828
:function-arn "arn:aws:lambda:...:dog-bark:HEAD"
:last-modified "2015-07-04T17:13:25.476+0000"
:runtime "nodejs"
:memory-size 128,
:default-version "HEAD"
:timeout 3
:version "HEAD"
:handler "index.cljs_lambda_example_dog_bark"
:code-sha-256 "2jpacR4ZbVXJ7WPaRUGxd/GNduKGpng/8br1c6g89Lg="
:function-name "dog-bark"}}