Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bunt/queue

Package Overview
Dependencies
Maintainers
1
Versions
127
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bunt/queue - npm Package Compare versions

Comparing version 0.29.15 to 0.29.16

6

dist/esm/Concurrency/ConcurrencyQueue.js

@@ -1,5 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConcurrencyQueue = void 0;
class ConcurrencyQueue {
export class ConcurrencyQueue {
#queue = new Set();

@@ -22,3 +19,2 @@ #concurrency;

}
exports.ConcurrencyQueue = ConcurrencyQueue;
//# sourceMappingURL=ConcurrencyQueue.js.map

@@ -1,19 +0,3 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./ConcurrencyQueue.js"), exports);
__exportStar(require("./RateLimitedQueue.js"), exports);
export * from "./ConcurrencyQueue.js";
export * from "./RateLimitedQueue.js";
//# sourceMappingURL=index.js.map

12

dist/esm/Concurrency/RateLimitedQueue.js

@@ -1,7 +0,4 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RateLimitedQueue = void 0;
const async_1 = require("@bunt/async");
const ConcurrencyQueue_js_1 = require("./ConcurrencyQueue.js");
class RateLimitedQueue extends ConcurrencyQueue_js_1.ConcurrencyQueue {
import { Defer } from "@bunt/async";
import { ConcurrencyQueue } from "./ConcurrencyQueue.js";
export class RateLimitedQueue extends ConcurrencyQueue {
#slots = [];

@@ -37,3 +34,3 @@ #pending = [];

}
const defer = new async_1.Defer();
const defer = new Defer();
this.#pending.push(defer);

@@ -51,3 +48,2 @@ return defer;

}
exports.RateLimitedQueue = RateLimitedQueue;
//# sourceMappingURL=RateLimitedQueue.js.map

@@ -1,2 +0,1 @@

"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

@@ -8,7 +7,5 @@ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;

};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Dispatcher = void 0;
const unit_1 = require("@bunt/unit");
const util_1 = require("@bunt/util");
class Dispatcher extends unit_1.Disposer {
import { Disposer, Heartbeat, unit, } from "@bunt/unit";
import { Defer, logger } from "@bunt/util";
export class Dispatcher extends Disposer {
#unit;

@@ -27,8 +24,8 @@ #queue;

static async factory(context, queue) {
return new this(await (0, unit_1.unit)(context), queue);
return new this(await unit(context), queue);
}
getHeartbeat() {
const running = new util_1.Defer();
const running = new Defer();
this.onDispose(() => running.resolve());
return unit_1.Heartbeat.create(this)
return Heartbeat.create(this)
.enqueue(running)

@@ -52,6 +49,5 @@ .onDispose(this);

}
exports.Dispatcher = Dispatcher;
__decorate([
util_1.logger
logger
], Dispatcher.prototype, "logger", void 0);
//# sourceMappingURL=Dispatcher.js.map

@@ -1,6 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Handler = void 0;
const unit_1 = require("@bunt/unit");
class Handler extends unit_1.Action {
import { Action } from "@bunt/unit";
export class Handler extends Action {
get payload() {

@@ -10,3 +7,2 @@ return this.state.payload;

}
exports.Handler = Handler;
//# sourceMappingURL=Handler.js.map

@@ -1,24 +0,8 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./Queue/index.js"), exports);
__exportStar(require("./Redis/index.js"), exports);
__exportStar(require("./Handler.js"), exports);
__exportStar(require("./interfaces.js"), exports);
__exportStar(require("./Dispatcher.js"), exports);
__exportStar(require("./PubSub/index.js"), exports);
__exportStar(require("./Concurrency/index.js"), exports);
export * from "./Queue/index.js";
export * from "./Redis/index.js";
export * from "./Handler.js";
export * from "./interfaces.js";
export * from "./Dispatcher.js";
export * from "./PubSub/index.js";
export * from "./Concurrency/index.js";
//# sourceMappingURL=index.js.map

@@ -1,3 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
export {};
//# sourceMappingURL=interfaces.js.map

@@ -1,24 +0,8 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./interfaces.js"), exports);
__exportStar(require("./PubSubAbstract.js"), exports);
__exportStar(require("./PubSubSimple.js"), exports);
__exportStar(require("./Subscription.js"), exports);
__exportStar(require("./SubscriptionManager.js"), exports);
__exportStar(require("./SubscriptionIterator.js"), exports);
__exportStar(require("./SubscriptionList.js"), exports);
export * from "./interfaces.js";
export * from "./PubSubAbstract.js";
export * from "./PubSubSimple.js";
export * from "./Subscription.js";
export * from "./SubscriptionManager.js";
export * from "./SubscriptionIterator.js";
export * from "./SubscriptionList.js";
//# sourceMappingURL=index.js.map

@@ -1,5 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SubscriptionListenerId = void 0;
exports.SubscriptionListenerId = Symbol.for("SubscriptionListenerId");
export const SubscriptionListenerId = Symbol.for("SubscriptionListenerId");
//# sourceMappingURL=interfaces.js.map

@@ -1,8 +0,5 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PubSubAbstract = void 0;
const unit_1 = require("@bunt/unit");
const util_1 = require("@bunt/util");
const Subscription_js_1 = require("./Subscription.js");
class PubSubAbstract extends unit_1.Disposer {
import { Disposer } from "@bunt/unit";
import { isArray } from "@bunt/util";
import { Subscription } from "./Subscription.js";
export class PubSubAbstract extends Disposer {
#transport;

@@ -15,3 +12,3 @@ constructor(transport) {

key(channel) {
return (0, util_1.isArray)(channel) ? channel.join("/") : channel;
return isArray(channel) ? channel.join("/") : channel;
}

@@ -22,6 +19,5 @@ async publish(channel, message) {

async subscribe(channel) {
return new Subscription_js_1.Subscription(this.key(channel), await this.#transport.getSubscriptionManager(), (message) => this.parse(message));
return new Subscription(this.key(channel), await this.#transport.getSubscriptionManager(), (message) => this.parse(message));
}
}
exports.PubSubAbstract = PubSubAbstract;
//# sourceMappingURL=PubSubAbstract.js.map

@@ -1,6 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PubSubSimple = void 0;
const PubSubAbstract_js_1 = require("./PubSubAbstract.js");
class PubSubSimple extends PubSubAbstract_js_1.PubSubAbstract {
import { PubSubAbstract } from "./PubSubAbstract.js";
export class PubSubSimple extends PubSubAbstract {
serialize(message) {

@@ -13,3 +10,2 @@ return JSON.stringify(message);

}
exports.PubSubSimple = PubSubSimple;
//# sourceMappingURL=PubSubSimple.js.map

@@ -1,7 +0,4 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Subscription = void 0;
const util_1 = require("@bunt/util");
const SubscriptionIterator_js_1 = require("./SubscriptionIterator.js");
class Subscription {
import { all } from "@bunt/util";
import { SubscriptionIterator } from "./SubscriptionIterator.js";
export class Subscription {
channel;

@@ -30,6 +27,6 @@ #parser;

}
await (0, util_1.all)(pending);
await all(pending);
}
[Symbol.asyncIterator]() {
const iterator = new SubscriptionIterator_js_1.SubscriptionIterator();
const iterator = new SubscriptionIterator();
const id = this.#manager.on(this.channel, (message) => iterator.push(this.#parser(message)));

@@ -47,3 +44,2 @@ iterator.unsubscribe(() => {

}
exports.Subscription = Subscription;
//# sourceMappingURL=Subscription.js.map

@@ -1,6 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SubscriptionIterator = void 0;
const util_1 = require("@bunt/util");
class SubscriptionIterator extends util_1.AsyncPool {
import { AsyncPool, isUndefined } from "@bunt/util";
export class SubscriptionIterator extends AsyncPool {
#unsubscribe;

@@ -10,3 +7,3 @@ #done = false;

const value = await this.pull();
if ((0, util_1.isUndefined)(value)) {
if (isUndefined(value)) {
return { value, done: true };

@@ -31,3 +28,2 @@ }

}
exports.SubscriptionIterator = SubscriptionIterator;
//# sourceMappingURL=SubscriptionIterator.js.map

@@ -1,6 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SubscriptionList = void 0;
const util_1 = require("@bunt/util");
class SubscriptionList {
import { safeMap } from "@bunt/util";
export class SubscriptionList {
#listeners = new Set();

@@ -23,3 +20,3 @@ channel;

emit(message) {
(0, util_1.safeMap)(this.#listeners.values(), (listener) => listener(message));
safeMap(this.#listeners.values(), (listener) => listener(message));
return this;

@@ -31,3 +28,2 @@ }

}
exports.SubscriptionList = SubscriptionList;
//# sourceMappingURL=SubscriptionList.js.map

@@ -1,2 +0,1 @@

"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

@@ -8,8 +7,6 @@ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;

};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SubscriptionManager = void 0;
const util_1 = require("@bunt/util");
const interfaces_js_1 = require("./interfaces.js");
const SubscriptionList_js_1 = require("./SubscriptionList.js");
class SubscriptionManager {
import { assert, Defer, logger } from "@bunt/util";
import { SubscriptionListenerId } from "./interfaces.js";
import { SubscriptionList } from "./SubscriptionList.js";
export class SubscriptionManager {
#subscriptions = new Map();

@@ -28,3 +25,3 @@ channels() {

subscriptionList.add(listener);
return { channel, [interfaces_js_1.SubscriptionListenerId]: listener };
return { channel, [SubscriptionListenerId]: listener };
}

@@ -38,3 +35,3 @@ off(id) {

const [subscriptionList] = config;
subscriptionList.delete(id[interfaces_js_1.SubscriptionListenerId]);
subscriptionList.delete(id[SubscriptionListenerId]);
if (!subscriptionList.count) {

@@ -48,3 +45,3 @@ this.#subscriptions.delete(id.channel);

const config = this.#subscriptions.get(channel);
(0, util_1.assert)(config, `No active subscriptions found for channel ${channel}`);
assert(config, `No active subscriptions found for channel ${channel}`);
return config[1];

@@ -70,3 +67,3 @@ }

this.logger.debug("createSubscriptionRecord(%s)", channel);
const config = [new SubscriptionList_js_1.SubscriptionList(channel), new util_1.Defer()];
const config = [new SubscriptionList(channel), new Defer()];
this.#subscriptions.set(channel, config);

@@ -76,6 +73,5 @@ return config;

}
exports.SubscriptionManager = SubscriptionManager;
__decorate([
util_1.logger
logger
], SubscriptionManager.prototype, "logger", void 0);
//# sourceMappingURL=SubscriptionManager.js.map

@@ -1,31 +0,5 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.isMessageParser = exports.isMessageSerializer = exports.isTransactionMessage = exports.createReleaseState = exports.tryUnserialize = exports.unserialize = exports.serialize = void 0;
const crypto = __importStar(require("crypto"));
const util_1 = require("@bunt/util");
import * as crypto from "crypto";
import { assert } from "@bunt/util";
const serializeRe = /^[0-9a-f]{8}:.+$/;
function serialize(message) {
export function serialize(message) {
const body = isMessageSerializer(message)

@@ -40,5 +14,4 @@ ? message.serialize()

}
exports.serialize = serialize;
function unserialize(type, message) {
(0, util_1.assert)(serializeRe.test(message), "Wrong message format");
export function unserialize(type, message) {
assert(serializeRe.test(message), "Wrong message format");
const body = message.substring(9);

@@ -50,3 +23,3 @@ const signature = message.substring(0, 8);

.substring(0, 8);
(0, util_1.assert)(signature === compareSignature, "Wrong checksum");
assert(signature === compareSignature, "Wrong checksum");
return isMessageParser(type)

@@ -56,4 +29,3 @@ ? type.parse(body)

}
exports.unserialize = unserialize;
function tryUnserialize(type, message) {
export function tryUnserialize(type, message) {
if (!message) {

@@ -71,4 +43,3 @@ return;

}
exports.tryUnserialize = tryUnserialize;
function createReleaseState(message) {
export function createReleaseState(message) {
const runAt = new Date();

@@ -87,16 +58,12 @@ return ((error) => {

}
exports.createReleaseState = createReleaseState;
function isTransactionMessage(type) {
export function isTransactionMessage(type) {
return Reflect.has(type, "getBackupKey")
&& Reflect.has(type, "getFallbackKey");
}
exports.isTransactionMessage = isTransactionMessage;
function isMessageSerializer(target) {
export function isMessageSerializer(target) {
return "serialize" in target;
}
exports.isMessageSerializer = isMessageSerializer;
function isMessageParser(target) {
export function isMessageParser(target) {
return "parse" in target;
}
exports.isMessageParser = isMessageParser;
//# sourceMappingURL=fn.js.map

@@ -1,26 +0,10 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./fn.js"), exports);
__exportStar(require("./interfaces.js"), exports);
__exportStar(require("./Message/index.js"), exports);
__exportStar(require("./QueueListAbstract.js"), exports);
__exportStar(require("./QueueList.js"), exports);
__exportStar(require("./QueueAbstract.js"), exports);
__exportStar(require("./Queue.js"), exports);
__exportStar(require("./QueueReaderAbstract.js"), exports);
__exportStar(require("./ReadOperation.js"), exports);
export * from "./fn.js";
export * from "./interfaces.js";
export * from "./Message/index.js";
export * from "./QueueListAbstract.js";
export * from "./QueueList.js";
export * from "./QueueAbstract.js";
export * from "./Queue.js";
export * from "./QueueReaderAbstract.js";
export * from "./ReadOperation.js";
//# sourceMappingURL=index.js.map

@@ -1,3 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
export {};
//# sourceMappingURL=interfaces.js.map

@@ -1,5 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IncomingMessageAbstract = void 0;
class IncomingMessageAbstract {
export class IncomingMessageAbstract {
payload;

@@ -17,3 +14,2 @@ static concurrency = 1;

}
exports.IncomingMessageAbstract = IncomingMessageAbstract;
//# sourceMappingURL=IncomingMessageAbstract.js.map

@@ -1,20 +0,4 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./MessageAbstract.js"), exports);
__exportStar(require("./TransactionAbstract.js"), exports);
__exportStar(require("./TaskAbstract.js"), exports);
export * from "./MessageAbstract.js";
export * from "./TransactionAbstract.js";
export * from "./TaskAbstract.js";
//# sourceMappingURL=index.js.map

@@ -1,8 +0,4 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MessageAbstract = void 0;
const IncomingMessageAbstract_js_1 = require("./IncomingMessageAbstract.js");
class MessageAbstract extends IncomingMessageAbstract_js_1.IncomingMessageAbstract {
import { IncomingMessageAbstract } from "./IncomingMessageAbstract.js";
export class MessageAbstract extends IncomingMessageAbstract {
}
exports.MessageAbstract = MessageAbstract;
//# sourceMappingURL=MessageAbstract.js.map

@@ -1,8 +0,4 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TaskAbstract = void 0;
const IncomingMessageAbstract_js_1 = require("./IncomingMessageAbstract.js");
class TaskAbstract extends IncomingMessageAbstract_js_1.IncomingMessageAbstract {
import { IncomingMessageAbstract } from "./IncomingMessageAbstract.js";
export class TaskAbstract extends IncomingMessageAbstract {
}
exports.TaskAbstract = TaskAbstract;
//# sourceMappingURL=TaskAbstract.js.map

@@ -1,9 +0,6 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TransactionAbstract = void 0;
const os_1 = require("os");
const MessageAbstract_js_1 = require("./MessageAbstract.js");
class TransactionAbstract extends MessageAbstract_js_1.MessageAbstract {
import { hostname } from "os";
import { MessageAbstract } from "./MessageAbstract.js";
export class TransactionAbstract extends MessageAbstract {
static getBackupKey() {
return `${this.channel}:backup:${(0, os_1.hostname)()}`;
return `${this.channel}:backup:${hostname()}`;
}

@@ -14,3 +11,2 @@ static getFallbackKey() {

}
exports.TransactionAbstract = TransactionAbstract;
//# sourceMappingURL=TransactionAbstract.js.map

@@ -1,8 +0,4 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Queue = void 0;
const QueueAbstract_js_1 = require("./QueueAbstract.js");
class Queue extends QueueAbstract_js_1.QueueAbstract {
import { QueueAbstract } from "./QueueAbstract.js";
export class Queue extends QueueAbstract {
}
exports.Queue = Queue;
//# sourceMappingURL=Queue.js.map

@@ -1,6 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.QueueAbstract = void 0;
const unit_1 = require("@bunt/unit");
class QueueAbstract extends unit_1.Disposer {
import { Disposer } from "@bunt/unit";
export class QueueAbstract extends Disposer {
#transport;

@@ -30,3 +27,2 @@ constructor(transport) {

}
exports.QueueAbstract = QueueAbstract;
//# sourceMappingURL=QueueAbstract.js.map

@@ -1,8 +0,4 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.QueueList = void 0;
const QueueListAbstract_js_1 = require("./QueueListAbstract.js");
class QueueList extends QueueListAbstract_js_1.QueueListAbstract {
import { QueueListAbstract } from "./QueueListAbstract.js";
export class QueueList extends QueueListAbstract {
}
exports.QueueList = QueueList;
//# sourceMappingURL=QueueList.js.map

@@ -1,9 +0,6 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.QueueListAbstract = void 0;
const unit_1 = require("@bunt/unit");
const util_1 = require("@bunt/util");
const ConcurrencyQueue_js_1 = require("../Concurrency/ConcurrencyQueue.js");
const index_js_1 = require("./Message/index.js");
class QueueListAbstract extends unit_1.Disposer {
import { Disposer } from "@bunt/unit";
import { assert, isDefined, isInstanceOf, toError } from "@bunt/util";
import { ConcurrencyQueue } from "../Concurrency/ConcurrencyQueue.js";
import { TaskAbstract } from "./Message/index.js";
export class QueueListAbstract extends Disposer {
#type;

@@ -24,3 +21,3 @@ #reader;

this.#state = this.listen();
this.#queue = new ConcurrencyQueue_js_1.ConcurrencyQueue(type.concurrency);
this.#queue = new ConcurrencyQueue(type.concurrency);
this.onDispose(this.#reader);

@@ -34,3 +31,3 @@ this.onDispose(() => this.unsubscribe());

async subscribe() {
(0, util_1.assert)(!this.subscribed, `The ${this.#type.channel} channel already subscribed`);
assert(!this.subscribed, `The ${this.#type.channel} channel already subscribed`);
this.#subscribed = true;

@@ -63,3 +60,3 @@ this.#state = this.listen();

const reply = await this.#handler(message);
if ((0, util_1.isDefined)(reply) && (0, util_1.isInstanceOf)(message, index_js_1.TaskAbstract)) {
if (isDefined(reply) && isInstanceOf(message, TaskAbstract)) {
await this.#transport.send(message.reply(reply));

@@ -70,3 +67,3 @@ }

catch (error) {
await this.fire(operation.rollback((0, util_1.toError)(error, "Unexpected error")));
await this.fire(operation.rollback(toError(error, "Unexpected error")));
}

@@ -82,3 +79,2 @@ }

}
exports.QueueListAbstract = QueueListAbstract;
//# sourceMappingURL=QueueListAbstract.js.map

@@ -1,6 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.QueueReaderAbstract = void 0;
const fn_js_1 = require("./fn.js");
class QueueReaderAbstract {
import { tryUnserialize } from "./fn.js";
export class QueueReaderAbstract {
#type;

@@ -17,3 +14,3 @@ constructor(type) {

async read() {
const message = (0, fn_js_1.tryUnserialize)(this.type, await this.next());
const message = tryUnserialize(this.type, await this.next());
if (message) {

@@ -24,3 +21,2 @@ return this.createReadOperation(new this.#type(message));

}
exports.QueueReaderAbstract = QueueReaderAbstract;
//# sourceMappingURL=QueueReaderAbstract.js.map

@@ -1,7 +0,4 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReadOperation = void 0;
const util_1 = require("@bunt/util");
const fn_js_1 = require("./fn.js");
class ReadOperation {
import { toError } from "@bunt/util";
import { createReleaseState } from "./fn.js";
export class ReadOperation {
#message;

@@ -11,3 +8,3 @@ #release;

this.#message = message;
this.#release = (0, fn_js_1.createReleaseState)(message);
this.#release = createReleaseState(message);
}

@@ -25,3 +22,3 @@ get channel() {

catch (error) {
return this.release((0, util_1.toError)(error, "Unexpected error"));
return this.release(toError(error, "Unexpected error"));
}

@@ -39,3 +36,2 @@ }

}
exports.ReadOperation = ReadOperation;
//# sourceMappingURL=ReadOperation.js.map

@@ -1,10 +0,4 @@

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createConnection = void 0;
const url_1 = require("url");
const util_1 = require("@bunt/util");
const ioredis_1 = __importDefault(require("ioredis"));
import { parse } from "url";
import { isString } from "@bunt/util";
import RedisClient from "ioredis";
const toBoolean = (value) => {

@@ -30,12 +24,12 @@ return ["Y", "y", "1", "true"].includes(value);

};
function createConnection(dsn, options) {
export function createConnection(dsn, options) {
if (dsn) {
const { hostname, port, query } = (0, url_1.parse)(dsn, true);
const { hostname, port, query } = parse(dsn, true);
const queryOptions = {};
for (const [key, value] of Object.entries(query)) {
if ((0, util_1.isString)(value) && Reflect.has(normalize, key)) {
if (isString(value) && Reflect.has(normalize, key)) {
Reflect.set(queryOptions, key, normalize[key](value));
}
}
return new ioredis_1.default({
return new RedisClient({
host: hostname ?? "localhost",

@@ -47,5 +41,4 @@ port: +(port ?? 6379),

}
return new ioredis_1.default();
return new RedisClient();
}
exports.createConnection = createConnection;
//# sourceMappingURL=fn.js.map

@@ -1,24 +0,8 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./fn.js"), exports);
__exportStar(require("./RedisQueueReader.js"), exports);
__exportStar(require("./RedisQ2Reader.js"), exports);
__exportStar(require("./RedisQ2ReadOperation.js"), exports);
__exportStar(require("./RedisQueueList.js"), exports);
__exportStar(require("./RedisTransport.js"), exports);
__exportStar(require("./RedisSubscriptionManager.js"), exports);
export * from "./fn.js";
export * from "./RedisQueueReader.js";
export * from "./RedisQ2Reader.js";
export * from "./RedisQ2ReadOperation.js";
export * from "./RedisQueueList.js";
export * from "./RedisTransport.js";
export * from "./RedisSubscriptionManager.js";
//# sourceMappingURL=index.js.map

@@ -1,7 +0,4 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RedisQ2Reader = void 0;
const RedisQ2ReadOperation_js_1 = require("./RedisQ2ReadOperation.js");
const RedisQueueReader_js_1 = require("./RedisQueueReader.js");
class RedisQ2Reader extends RedisQueueReader_js_1.RedisQueueReader {
import { RedisQ2ReadOperation } from "./RedisQ2ReadOperation.js";
import { RedisQueueReader } from "./RedisQueueReader.js";
export class RedisQ2Reader extends RedisQueueReader {
get backup() {

@@ -17,3 +14,3 @@ return this.type.getBackupKey();

createReadOperation(message) {
return new RedisQ2ReadOperation_js_1.RedisQ2ReadOperation(message, this.commit, this.rollback);
return new RedisQ2ReadOperation(message, this.commit, this.rollback);
}

@@ -27,3 +24,2 @@ commit = async () => {

}
exports.RedisQ2Reader = RedisQ2Reader;
//# sourceMappingURL=RedisQ2Reader.js.map

@@ -1,7 +0,4 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RedisQ2ReadOperation = void 0;
const util_1 = require("@bunt/util");
const index_js_1 = require("../Queue/index.js");
class RedisQ2ReadOperation extends index_js_1.ReadOperation {
import { toError } from "@bunt/util";
import { ReadOperation } from "../Queue/index.js";
export class RedisQ2ReadOperation extends ReadOperation {
#commit;

@@ -19,3 +16,3 @@ #rollback;

catch (error) {
return this.release((0, util_1.toError)(error, "Unknown"));
return this.release(toError(error, "Unknown"));
}

@@ -29,3 +26,3 @@ return this.release();

catch (error) {
return this.release((0, util_1.toError)(error, "Unexpected error"));
return this.release(toError(error, "Unexpected error"));
}

@@ -35,3 +32,2 @@ return this.release(reason ?? new Error("Unknown reason"));

}
exports.RedisQ2ReadOperation = RedisQ2ReadOperation;
//# sourceMappingURL=RedisQ2ReadOperation.js.map

@@ -1,8 +0,4 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RedisQueueList = void 0;
const index_js_1 = require("../Queue/index.js");
class RedisQueueList extends index_js_1.QueueListAbstract {
import { QueueListAbstract } from "../Queue/index.js";
export class RedisQueueList extends QueueListAbstract {
}
exports.RedisQueueList = RedisQueueList;
//# sourceMappingURL=RedisQueueList.js.map

@@ -1,6 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RedisQueueReader = void 0;
const index_js_1 = require("../Queue/index.js");
class RedisQueueReader extends index_js_1.QueueReaderAbstract {
import { QueueReaderAbstract, ReadOperation } from "../Queue/index.js";
export class RedisQueueReader extends QueueReaderAbstract {
timeout = 100;

@@ -29,3 +26,3 @@ #connection;

createReadOperation(message) {
return new index_js_1.ReadOperation(message);
return new ReadOperation(message);
}

@@ -36,3 +33,2 @@ wrap(result) {

}
exports.RedisQueueReader = RedisQueueReader;
//# sourceMappingURL=RedisQueueReader.js.map

@@ -1,6 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RedisSubscriptionManager = void 0;
const index_js_1 = require("../PubSub/index.js");
class RedisSubscriptionManager extends index_js_1.SubscriptionManager {
import { SubscriptionManager } from "../PubSub/index.js";
export class RedisSubscriptionManager extends SubscriptionManager {
#transport;

@@ -30,3 +27,2 @@ #connection;

}
exports.RedisSubscriptionManager = RedisSubscriptionManager;
//# sourceMappingURL=RedisSubscriptionManager.js.map

@@ -1,13 +0,10 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RedisTransport = void 0;
const unit_1 = require("@bunt/unit");
const util_1 = require("@bunt/util");
const index_js_1 = require("../Queue/index.js");
const fn_js_1 = require("./fn.js");
const RedisQ2Reader_js_1 = require("./RedisQ2Reader.js");
const RedisQueueList_js_1 = require("./RedisQueueList.js");
const RedisQueueReader_js_1 = require("./RedisQueueReader.js");
const RedisSubscriptionManager_js_1 = require("./RedisSubscriptionManager.js");
class RedisTransport extends unit_1.Disposer {
import { Disposer } from "@bunt/unit";
import { Defer } from "@bunt/util";
import { isTransactionMessage, serialize } from "../Queue/index.js";
import { createConnection } from "./fn.js";
import { RedisQ2Reader } from "./RedisQ2Reader.js";
import { RedisQueueList } from "./RedisQueueList.js";
import { RedisQueueReader } from "./RedisQueueReader.js";
import { RedisSubscriptionManager } from "./RedisSubscriptionManager.js";
export class RedisTransport extends Disposer {
#connection;

@@ -19,3 +16,3 @@ #clients = new WeakMap();

super();
this.#connection = this.watch((0, fn_js_1.createConnection)(dsn, options));
this.#connection = this.watch(createConnection(dsn, options));
}

@@ -36,3 +33,3 @@ get connection() {

this.logger.debug("send(%s, %o)", message.channel, message.payload);
await this.#connection.lpush(message.channel, (0, index_js_1.serialize)(message));
await this.#connection.lpush(message.channel, serialize(message));
}

@@ -47,9 +44,9 @@ async publish(channel, message) {

getQueueList(type, handler) {
return this.register(new RedisQueueList_js_1.RedisQueueList(this, type, handler));
return this.register(new RedisQueueList(this, type, handler));
}
getQueueReader(type) {
if ((0, index_js_1.isTransactionMessage)(type)) {
return this.register(new RedisQ2Reader_js_1.RedisQ2Reader(this, type));
if (isTransactionMessage(type)) {
return this.register(new RedisQ2Reader(this, type));
}
return this.register(new RedisQueueReader_js_1.RedisQueueReader(this, type));
return this.register(new RedisQueueReader(this, type));
}

@@ -59,3 +56,3 @@ async getSubscriptionManager() {

this.logger.debug("getSubscriptionManager(): new RedisSubscriptionManager()");
this.#subscriptionManager = this.register(new RedisSubscriptionManager_js_1.RedisSubscriptionManager(this));
this.#subscriptionManager = this.register(new RedisSubscriptionManager(this));
}

@@ -71,3 +68,3 @@ return this.#subscriptionManager;

this.logger.debug("connection(watch)");
const connectionState = new util_1.Defer();
const connectionState = new Defer();
this.#clients.set(connection, connectionState);

@@ -89,3 +86,2 @@ return connection

}
exports.RedisTransport = RedisTransport;
//# sourceMappingURL=RedisTransport.js.map
{
"name": "@bunt/queue",
"version": "0.29.15",
"version": "0.29.16",
"keywords": [

@@ -36,9 +36,9 @@ "typescript"

"dependencies": {
"@bunt/async": "^0.29.15",
"@bunt/unit": "^0.29.15",
"@bunt/util": "^0.29.15",
"@bunt/async": "^0.29.16",
"@bunt/unit": "^0.29.16",
"@bunt/util": "^0.29.16",
"ioredis": "^5.3.2"
},
"license": "MIT",
"gitHead": "c51511e885a99ea220708c6329ffa4ac4550e14e"
"gitHead": "6d4993cad2d32f4c402b89685fc92f2db8df2cf6"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc