@vercel/queue 0.1.6 → 0.2.0
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/dist/index.d.mts +68 -1
- package/dist/index.d.ts +68 -1
- package/dist/index.js +41 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -941,6 +941,44 @@ Add a trigger to vercel.json:
|
|
|
941
941
|
);
|
|
942
942
|
}
|
|
943
943
|
}
|
|
944
|
+
function registerDevConsumer(options) {
|
|
945
|
+
const {
|
|
946
|
+
topic,
|
|
947
|
+
client,
|
|
948
|
+
handler,
|
|
949
|
+
consumerGroup = "dev-consumer",
|
|
950
|
+
visibilityTimeoutSeconds,
|
|
951
|
+
retry
|
|
952
|
+
} = options;
|
|
953
|
+
const entry = {
|
|
954
|
+
consumerGroup,
|
|
955
|
+
handler,
|
|
956
|
+
client,
|
|
957
|
+
options: visibilityTimeoutSeconds !== void 0 || retry !== void 0 ? { visibilityTimeoutSeconds, retry } : void 0
|
|
958
|
+
};
|
|
959
|
+
const registry = getHandlerRegistry();
|
|
960
|
+
const existing = registry.get(topic) ?? [];
|
|
961
|
+
const existingIndex = existing.findIndex(
|
|
962
|
+
(e) => e.consumerGroup === consumerGroup
|
|
963
|
+
);
|
|
964
|
+
if (existingIndex >= 0) {
|
|
965
|
+
existing[existingIndex] = entry;
|
|
966
|
+
} else {
|
|
967
|
+
existing.push(entry);
|
|
968
|
+
}
|
|
969
|
+
registry.set(topic, existing);
|
|
970
|
+
return () => {
|
|
971
|
+
const current = registry.get(topic);
|
|
972
|
+
if (!current) return;
|
|
973
|
+
const filtered = current.filter((e) => e !== entry);
|
|
974
|
+
if (filtered.length === current.length) return;
|
|
975
|
+
if (filtered.length === 0) {
|
|
976
|
+
registry.delete(topic);
|
|
977
|
+
} else {
|
|
978
|
+
registry.set(topic, filtered);
|
|
979
|
+
}
|
|
980
|
+
};
|
|
981
|
+
}
|
|
944
982
|
function lookupHandlers(topicName) {
|
|
945
983
|
const registry = getHandlerRegistry();
|
|
946
984
|
const result = [];
|
|
@@ -1579,7 +1617,7 @@ Cause: ${cause}`
|
|
|
1579
1617
|
}
|
|
1580
1618
|
console.debug("[VQS Debug] Request:", JSON.stringify(logData, null, 2));
|
|
1581
1619
|
}
|
|
1582
|
-
init.headers.set("User-Agent", `@vercel/queue/${"0.
|
|
1620
|
+
init.headers.set("User-Agent", `@vercel/queue/${"0.2.0"}`);
|
|
1583
1621
|
init.headers.set("Vqs-Client-Ts", (/* @__PURE__ */ new Date()).toISOString());
|
|
1584
1622
|
const fetchInit = this.dispatcher ? { ...init, dispatcher: this.dispatcher } : init;
|
|
1585
1623
|
const response = await fetch(url, fetchInit);
|
|
@@ -2268,6 +2306,7 @@ export {
|
|
|
2268
2306
|
handleCallback2 as handleCallback,
|
|
2269
2307
|
parseCallback,
|
|
2270
2308
|
parseRawCallback,
|
|
2309
|
+
registerDevConsumer,
|
|
2271
2310
|
send
|
|
2272
2311
|
};
|
|
2273
2312
|
//# sourceMappingURL=index.mjs.map
|