procedere-mq-sdk 0.3.0 → 0.3.1
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/index.js +12 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -28,10 +28,11 @@ class Producer {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
async publish(payload = null, options = {}) {
|
|
31
|
-
const { jobId, maxRetry, runAt } = options;
|
|
31
|
+
const { jobId, maxRetry, visibilityTimeout, runAt } = options;
|
|
32
32
|
return this.client.enqueue(this.queue, payload, {
|
|
33
33
|
jobId,
|
|
34
34
|
maxRetry,
|
|
35
|
+
visibilityTimeout,
|
|
35
36
|
runAt,
|
|
36
37
|
});
|
|
37
38
|
}
|
|
@@ -91,6 +92,9 @@ class LiteMQClient {
|
|
|
91
92
|
if (options.maxRetry !== undefined) {
|
|
92
93
|
body.max_retry = options.maxRetry;
|
|
93
94
|
}
|
|
95
|
+
if (options.visibilityTimeout !== undefined) {
|
|
96
|
+
body.visibility_timeout = options.visibilityTimeout;
|
|
97
|
+
}
|
|
94
98
|
if (options.runAt !== undefined && options.runAt !== null) {
|
|
95
99
|
body.run_at = formatDateTime(options.runAt);
|
|
96
100
|
}
|
|
@@ -118,6 +122,13 @@ class LiteMQClient {
|
|
|
118
122
|
});
|
|
119
123
|
}
|
|
120
124
|
|
|
125
|
+
async redrive(queue) {
|
|
126
|
+
const normalizedQueue = normalizeRequiredString(queue, "queue");
|
|
127
|
+
const params = new URLSearchParams({ queue: normalizedQueue });
|
|
128
|
+
const data = await this._request("POST", `/api/redrive?${params.toString()}`, 200);
|
|
129
|
+
return data.count || 0;
|
|
130
|
+
}
|
|
131
|
+
|
|
121
132
|
async _request(method, path, expectedStatus, options = {}) {
|
|
122
133
|
const controller = new AbortController();
|
|
123
134
|
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|