-
Notifications
You must be signed in to change notification settings - Fork 1
/
sqs.clj
57 lines (47 loc) · 2.11 KB
/
sqs.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
(ns gluttony.sqs
"wrapper of cognitect.aws.client.api"
(:require
[camel-snake-kebab.core :as csk]
[camel-snake-kebab.extras :as cske]
[clojure.core.async :as a]
[cognitect.aws.client.api :as aws]))
(defn- invoke-async
[client op-map]
(let [op-map (update op-map :request #(cske/transform-keys csk/->PascalCaseKeyword %))]
(a/go
(when-let [res (a/<! (aws/invoke-async client op-map))]
(cske/transform-keys csk/->kebab-case-keyword res)))))
(defn receive-message
"Retrieves one or more messages (up to 10), from the specified queue.
Input:
client - the SQS client, which is the instance of cognitect.aws.client.Client.
request - a map. See the result of (:request (:ReceiveMessage (aws/ops client))) but the keys can
be :kebab-case-keyword.
Output:
a channel will take a map. See the result of (:response (:ReceiveMessage (aws/ops client))) but the
keys are kebab-case-keyword."
[client request]
(invoke-async client {:op :ReceiveMessage :request request}))
(defn delete-message
"Deletes the specified message from the specified queue.
To select the message to delete, use the ReceiptHandle of the message.
Input:
client - the SQS client, which is the instance of cognitect.aws.client.Client.
request - a map. See the result of (:request (:DeleteMessage (aws/ops client))) but the keys can
be :kebab-case-keyword.
Output:
a channel will take nil."
[client request]
(invoke-async client {:op :DeleteMessage :request request}))
(defn change-message-visibility
"Changes the visibility timeout of a specified message in a queue to a new value.
The default visibility timeout for a message is 30 seconds.
The minimum is 0 seconds. The maximum is 12 hours.
Input:
client - the SQS client, which is the instance of cognitect.aws.client.Client.
request - a map. See the result of (:request (:ChangeMessageVisibility (aws/ops client))) but
the keys can be :kebab-case-keyword.
Output:
a channel will take nil."
[client request]
(invoke-async client {:op :ChangeMessageVisibility :request request}))