-
Notifications
You must be signed in to change notification settings - Fork 0
/
retry_request.js
54 lines (46 loc) · 1.46 KB
/
retry_request.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
49
50
51
52
53
54
const aws = require('aws-sdk');
const requestId = '';
if (requestId) {
const dynamoClient = new aws.DynamoDB({ region: 'us-west-2' });
const params = {
TableName: 'publish_requests',
Limit: 1,
IndexName: 'request_id-index',
ExpressionAttributeNames: {
'#requestId': 'request_id'
},
ExpressionAttributeValues: {
':requestId': {
S: requestId
}
},
KeyConditionExpression: '#requestId = :requestId'
}
console.log(params);
dynamoClient.query(params, (err, result) => {
console.log('wat this');
console.log(err);
console.log(result);
const gameId = result.Items[0].game_id.S;
const sourceInfoHash = result.Items[0].source_info_hash.S;
const messageBody = JSON.stringify({
gameId,
sourceInfoHash,
squishVersion: result.Items[0].squish_version.S
});
const sqsParams = {
MessageBody: messageBody,
MessageGroupId: `${Date.now()}`,
MessageDeduplicationId: requestId,
QueueUrl: // insert here
}
const sqs = new aws.SQS({ region: 'us-west-2' });
sqs.sendMessage(sqsParams, (err, sqsResponse) => {
console.log('sent request?');
console.log(err);
console.log(sqsResponse);
});
});
} else {
console.log('request id required');
}