qdone 2.0.41-alpha → 2.0.43-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qdone",
3
- "version": "2.0.41-alpha",
3
+ "version": "2.0.43-alpha",
4
4
  "description": "A distributed scheduler for SQS",
5
5
  "type": "module",
6
6
  "main": "./index.js",
package/src/consumer.js CHANGED
@@ -36,7 +36,7 @@ export async function getMessages (qrl, opt, maxMessages) {
36
36
  MaxNumberOfMessages: maxMessages,
37
37
  MessageAttributeNames: ['All'],
38
38
  QueueUrl: qrl,
39
- VisibilityTimeout: 60,
39
+ VisibilityTimeout: 120,
40
40
  WaitTimeSeconds: opt.waitTime
41
41
  }
42
42
  const response = await getSQSClient().send(new ReceiveMessageCommand(params))
package/src/dedup.js CHANGED
@@ -58,6 +58,9 @@ export function addDedupParamsToMessage (message, opt, messageOptions) {
58
58
  // Fallback to using the message body
59
59
  if (!message.MessageDeduplicationId) {
60
60
  message.MessageDeduplicationId = getDeduplicationId(message.MessageBody, opt)
61
+ } else {
62
+ // Transform the incoming ID so that it fits SPS spec and is suitable for Redis
63
+ message.MessageDeduplicationId = getDeduplicationId(message.MessageDeduplicationId, opt)
61
64
  }
62
65
 
63
66
  // Track our own dedup id so we can look it up upon ReceiveMessage
package/src/defaults.js CHANGED
@@ -53,7 +53,7 @@ export const defaults = Object.freeze({
53
53
  create: false
54
54
  })
55
55
 
56
- function validateInteger (opt, name) {
56
+ export function validateInteger (opt, name) {
57
57
  const parsed = parseInt(opt[name], 10)
58
58
  if (isNaN(parsed)) throw new Error(`${name} needs to be an integer.`)
59
59
  return parsed
@@ -117,7 +117,7 @@ export function getOptionsWithDefaults (options) {
117
117
  delay: options.delay || defaults.delay,
118
118
  sendRetries: options['send-retries'] || defaults.sendRetries,
119
119
  failDelay: options.failDelay || options['fail-delay'] || defaults.failDelay,
120
- dlq: dlq === false ? false : (dlq || defaults.dlq),
120
+ dlq: dlq === false ? false : defaults.dlq,
121
121
  dlqSuffix: options.dlqSuffix || options['dlq-suffix'] || defaults.dlqSuffix,
122
122
  dlqAfter: options.dlqAfter || options['dlq-after'] || defaults.dlqAfter,
123
123
  tags: options.tags || undefined,
@@ -159,7 +159,7 @@ export function getOptionsWithDefaults (options) {
159
159
 
160
160
  // Validate dedup args
161
161
  if (opt.externalDedup && !opt.cacheUri) throw new Error('--external-dedup requires the --cache-uri argument')
162
- if (opt.externalDedup && (!opt.dedupPeriod || opt.dedupPeriod < 1)) throw new Error('--external-dedup of redis requires a --dedup-period > 1 second')
162
+ if (opt.externalDedup && (opt.dedupPeriod < 1)) throw new Error('--external-dedup of redis requires a --dedup-period > 1 second')
163
163
  if (opt.dedupIdPerMessage && opt.deduplicationId) throw new Error('Use either --deduplication-id or --dedup-id-per-message but not both')
164
164
 
165
165
  return opt
@@ -168,6 +168,8 @@ export class JobExecutor {
168
168
  console.error('FAILED_MESSAGES', result.Failed)
169
169
  for (const failed of result.Failed) {
170
170
  console.error('FAILED_TO_EXTEND_JOB', this.jobsByMessageId[failed.Id])
171
+ // ensure that we clean this one up so it doesn't generate api calls
172
+ this.jobsbymessageid[failed.id].status = 'failed'
171
173
  }
172
174
  }
173
175
  if (result.Successful) {
@@ -210,6 +212,8 @@ export class JobExecutor {
210
212
  console.error('FAILED_MESSAGES', result.Failed)
211
213
  for (const failed of result.Failed) {
212
214
  console.error('FAILED_TO_DELETE_JOB', this.jobsByMessageId[failed.Id])
215
+ // ensure that we clean this one up so it doesn't generate api calls
216
+ this.jobsbymessageid[failed.id].status = 'failed'
213
217
  }
214
218
  }
215
219
  if (result.Successful) {
@@ -230,7 +234,6 @@ export class JobExecutor {
230
234
  }
231
235
  debug('DeleteMessageBatch returned', result)
232
236
 
233
-
234
237
  // TODO Sentry
235
238
  }
236
239
  }
@@ -251,7 +254,7 @@ export class JobExecutor {
251
254
 
252
255
  addJob (message, callback, qname, qrl) {
253
256
  // Create job entry and track it
254
- const defaultVisibilityTimeout = 60
257
+ const defaultVisibilityTimeout = 120
255
258
  const job = {
256
259
  status: 'waiting',
257
260
  start: new Date(),