-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
48 lines (42 loc) · 1.03 KB
/
index.js
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
var AWS = require("aws-sdk");
var sqs = new AWS.SQS({
maxRetries: 15,
region: process.env.HATCHET_QUEUE_REGION
});
module.exports = {
send: function(event_type, data, callback) {
if (typeof data !== "object") {
return;
}
var wrapper = {
app: process.env.HATCHET_APP_NAME,
event_type: event_type,
timestamp: (new Date()).toISOString(),
data: data
};
if (!process.env.HATCHET_QUEUE_URL) {
if (!process.env.HATCHET_NO_LOG) {
console.log("--- Hatchet message ---");
console.log(wrapper);
console.log("-----------------------");
}
if (callback) {
callback(null, {
MD5OfMessageBody: "fake",
MD5OfMessageAttributes: "fake",
MessageId: "fake"
});
}
return;
}
var body = JSON.stringify(wrapper);
sqs.sendMessage({
MessageBody: body,
QueueUrl: process.env.HATCHET_QUEUE_URL
}, function(err, data) {
if (callback) {
callback(err, data);
}
});
}
};