qdone 2.2.1 → 2.2.3
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/commonjs/src/dedup.js +3 -3
- package/commonjs/src/defaults.js +5 -3
- package/package.json +1 -1
- package/src/dedup.js +3 -3
- package/src/defaults.js +5 -3
package/commonjs/src/dedup.js
CHANGED
|
@@ -125,7 +125,7 @@ async function statMaintenance(opt) {
|
|
|
125
125
|
const duplicateSet = opt.cachePrefix + 'dedup-stats:duplicateSet';
|
|
126
126
|
const expirationSet = opt.cachePrefix + 'dedup-stats:expirationSet';
|
|
127
127
|
const client = (0, cache_js_1.getCacheClient)(opt);
|
|
128
|
-
const now =
|
|
128
|
+
const now = Math.floor(Date.now() / 1000);
|
|
129
129
|
// Grab a batch of expired keys
|
|
130
130
|
debug({ statMaintenance: { aboutToGo: true, expirationSet } });
|
|
131
131
|
const expiredStats = await client.zrange(expirationSet, '-inf', now, 'BYSCORE');
|
|
@@ -150,7 +150,7 @@ async function dedupShouldEnqueue(message, opt) {
|
|
|
150
150
|
const client = (0, cache_js_1.getCacheClient)(opt);
|
|
151
151
|
const dedupId = message?.MessageAttributes?.QdoneDeduplicationId?.StringValue;
|
|
152
152
|
const cacheKey = getCacheKey(dedupId, opt);
|
|
153
|
-
const expireAt =
|
|
153
|
+
const expireAt = Math.floor(Date.now() / 1000) + opt.dedupPeriod;
|
|
154
154
|
const copies = await client.incr(cacheKey);
|
|
155
155
|
debug({ action: 'shouldEnqueue', cacheKey, copies });
|
|
156
156
|
if (copies === 1) {
|
|
@@ -172,7 +172,7 @@ async function dedupShouldEnqueue(message, opt) {
|
|
|
172
172
|
*/
|
|
173
173
|
async function dedupShouldEnqueueMulti(messages, opt) {
|
|
174
174
|
debug({ dedupShouldEnqueueMulti: { messages, opt } });
|
|
175
|
-
const expireAt =
|
|
175
|
+
const expireAt = Math.floor(Date.now() / 1000) + opt.dedupPeriod;
|
|
176
176
|
// Increment all
|
|
177
177
|
const incrPipeline = (0, cache_js_1.getCacheClient)(opt).pipeline();
|
|
178
178
|
for (const message of messages) {
|
package/commonjs/src/defaults.js
CHANGED
|
@@ -94,8 +94,10 @@ function getOptionsWithDefaults(options) {
|
|
|
94
94
|
// For API invocations don't force caller to supply default options
|
|
95
95
|
if (!options)
|
|
96
96
|
options = {};
|
|
97
|
-
// Activate DLQ if any option is set
|
|
98
|
-
|
|
97
|
+
// Activate DLQ if any sub-option is set. Use ?? so that undefined (not
|
|
98
|
+
// passed) falls through to the default, while explicit false is preserved.
|
|
99
|
+
const hasDlqSubOption = !!(options['dlq-suffix'] || options['dlq-after'] || options['dlq-name'] || options.dlqSuffix || options.dlqAfter || options.dlqName);
|
|
100
|
+
const dlq = options.dlq ?? (hasDlqSubOption || undefined);
|
|
99
101
|
const opt = {
|
|
100
102
|
// Shared
|
|
101
103
|
prefix: options.prefix === '' ? options.prefix : (options.prefix || process.env.QDONE_PREFIX || exports.defaults.prefix),
|
|
@@ -124,7 +126,7 @@ function getOptionsWithDefaults(options) {
|
|
|
124
126
|
delay: options.delay || process.env.QDONE_DELAY || exports.defaults.delay,
|
|
125
127
|
sendRetries: options.sendRetries || options['send-retries'] || process.env.QDONE_SEND_RETRIES || exports.defaults.sendRetries,
|
|
126
128
|
failDelay: options.failDelay || options['fail-delay'] || process.env.QDONE_FAIL_DELAY || exports.defaults.failDelay,
|
|
127
|
-
dlq: dlq
|
|
129
|
+
dlq: dlq ?? exports.defaults.dlq,
|
|
128
130
|
dlqSuffix: options.dlqSuffix || options['dlq-suffix'] || process.env.QDONE_DLQ_SUFFIX || exports.defaults.dlqSuffix,
|
|
129
131
|
dlqAfter: options.dlqAfter || options['dlq-after'] || process.env.QDONE_DLQ_AFTER || exports.defaults.dlqAfter,
|
|
130
132
|
tags: options.tags || undefined,
|
package/package.json
CHANGED
package/src/dedup.js
CHANGED
|
@@ -112,7 +112,7 @@ export async function statMaintenance (opt) {
|
|
|
112
112
|
const duplicateSet = opt.cachePrefix + 'dedup-stats:duplicateSet'
|
|
113
113
|
const expirationSet = opt.cachePrefix + 'dedup-stats:expirationSet'
|
|
114
114
|
const client = getCacheClient(opt)
|
|
115
|
-
const now =
|
|
115
|
+
const now = Math.floor(Date.now() / 1000)
|
|
116
116
|
|
|
117
117
|
// Grab a batch of expired keys
|
|
118
118
|
debug({ statMaintenance: { aboutToGo: true, expirationSet } })
|
|
@@ -140,7 +140,7 @@ export async function dedupShouldEnqueue (message, opt) {
|
|
|
140
140
|
const client = getCacheClient(opt)
|
|
141
141
|
const dedupId = message?.MessageAttributes?.QdoneDeduplicationId?.StringValue
|
|
142
142
|
const cacheKey = getCacheKey(dedupId, opt)
|
|
143
|
-
const expireAt =
|
|
143
|
+
const expireAt = Math.floor(Date.now() / 1000) + opt.dedupPeriod
|
|
144
144
|
const copies = await client.incr(cacheKey)
|
|
145
145
|
debug({ action: 'shouldEnqueue', cacheKey, copies })
|
|
146
146
|
if (copies === 1) {
|
|
@@ -163,7 +163,7 @@ export async function dedupShouldEnqueue (message, opt) {
|
|
|
163
163
|
*/
|
|
164
164
|
export async function dedupShouldEnqueueMulti (messages, opt) {
|
|
165
165
|
debug({ dedupShouldEnqueueMulti: { messages, opt } })
|
|
166
|
-
const expireAt =
|
|
166
|
+
const expireAt = Math.floor(Date.now() / 1000) + opt.dedupPeriod
|
|
167
167
|
// Increment all
|
|
168
168
|
const incrPipeline = getCacheClient(opt).pipeline()
|
|
169
169
|
for (const message of messages) {
|
package/src/defaults.js
CHANGED
|
@@ -90,8 +90,10 @@ export function getOptionsWithDefaults (options) {
|
|
|
90
90
|
// For API invocations don't force caller to supply default options
|
|
91
91
|
if (!options) options = {}
|
|
92
92
|
|
|
93
|
-
// Activate DLQ if any option is set
|
|
94
|
-
|
|
93
|
+
// Activate DLQ if any sub-option is set. Use ?? so that undefined (not
|
|
94
|
+
// passed) falls through to the default, while explicit false is preserved.
|
|
95
|
+
const hasDlqSubOption = !!(options['dlq-suffix'] || options['dlq-after'] || options['dlq-name'] || options.dlqSuffix || options.dlqAfter || options.dlqName)
|
|
96
|
+
const dlq = options.dlq ?? (hasDlqSubOption || undefined)
|
|
95
97
|
|
|
96
98
|
const opt = {
|
|
97
99
|
// Shared
|
|
@@ -123,7 +125,7 @@ export function getOptionsWithDefaults (options) {
|
|
|
123
125
|
delay: options.delay || process.env.QDONE_DELAY || defaults.delay,
|
|
124
126
|
sendRetries: options.sendRetries || options['send-retries'] || process.env.QDONE_SEND_RETRIES || defaults.sendRetries,
|
|
125
127
|
failDelay: options.failDelay || options['fail-delay'] || process.env.QDONE_FAIL_DELAY || defaults.failDelay,
|
|
126
|
-
dlq: dlq
|
|
128
|
+
dlq: dlq ?? defaults.dlq,
|
|
127
129
|
dlqSuffix: options.dlqSuffix || options['dlq-suffix'] || process.env.QDONE_DLQ_SUFFIX || defaults.dlqSuffix,
|
|
128
130
|
dlqAfter: options.dlqAfter || options['dlq-after'] || process.env.QDONE_DLQ_AFTER || defaults.dlqAfter,
|
|
129
131
|
tags: options.tags || undefined,
|