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

@lynxvs/amqp

Package Overview
Dependencies
Maintainers
4
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lynxvs/amqp - npm Package Compare versions

Comparing version 3.0.2 to 3.0.3

1

error.d.ts

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

/// <reference types="node" />
import Raven from "raven";

@@ -3,0 +2,0 @@ /**

24

package.json
{
"name": "@lynxvs/amqp",
"version": "3.0.2",
"version": "3.0.3",
"description": "",

@@ -36,21 +36,21 @@ "main": "index.js",

"devDependencies": {
"@types/jest": "^22.2.3",
"babel-jest": "^22.4.3",
"@types/jest": "^23.0.0",
"babel-jest": "^23.6.0",
"coveralls": "^3.0.1",
"husky": "^0.15.0-rc.13",
"jest": "^22.4.3",
"jest": "^23.6.0",
"prettier": "^1.11.1",
"pretty-quick": "^1.4.1",
"ts-jest": "^22.4.4",
"ts-jest": "^23.10.5",
"tslint": "^5.9.1",
"tslint-config-prettier": "^1.10.0",
"typescript": "^2.8.1",
"raven": "~2.5",
"winston": "~3.1",
"express": "~4.16"
"typescript": "^3.3.1",
"raven": "^2.6.4",
"winston": "^3.2.1",
"express": "^4.16.4"
},
"peerDependencies": {
"raven": "~2.5",
"winston": "~3.1",
"express": "~4.16"
"raven": "^2.5",
"winston": "^3.1",
"express": "^4.16"
},

@@ -57,0 +57,0 @@ "husky": {

@@ -12,3 +12,3 @@ const amqplib = jest.genMockFromModule("amqplib");

createChannel() {
return this.channels.pop();
return this.channels.pop() || new Channel();
}

@@ -38,2 +38,3 @@

this.consumers = {};
this.exchanges = {};
}

@@ -45,3 +46,7 @@

sendToQueue(queue, message, options) {
assertExchange(exchange) {
this.exchanges[exchange] = [];
}
sendToQueue(queue, message) {
return Promise.all(

@@ -58,2 +63,6 @@ this.consumers[queue].map(consumer =>

publish(exchange, queue, message) {
// no op
}
consume(queue, onMessage) {

@@ -115,5 +124,5 @@ this.consumers[queue].push(onMessage);

amqplib.connect = () => {
return connections.pop();
return connections.pop() || new Connection();
};
module.exports = amqplib;

@@ -9,3 +9,3 @@ const amqplib = require("amqplib");

const ch: any = conn.__queueChannel();
await queue.publish("test", {});
await queue.publish("exchange_test", "routingKey_test", {});
expect(conn.closed).toBe(true);

@@ -20,3 +20,3 @@ expect(ch.closed).toBe(true);

const ch: any = conn.__queueChannel();
await queue.publishMessages("test", [{}]);
await queue.publishMessages("exchange_test", "routingKey_test", [{}]);
expect(conn.closed).toBe(true);

@@ -23,0 +23,0 @@ expect(ch.closed).toBe(true);

@@ -38,5 +38,12 @@ import * as worker from "../worker";

let called = false;
await worker.consume(conn, "ping", 1, async (message: Message) => {
called = true;
});
await worker.consume(
conn,
"ping",
"routingKey",
"queueName",
1,
async (message: Message) => {
called = true;
}
);

@@ -54,5 +61,12 @@ const msg = amqplib.__createMessage({});

setClosing(true);
await worker.consume(conn, "ping", 1, async (message: Message) => {
throw new Error();
});
await worker.consume(
conn,
"ping",
"routingKey",
"queueName",
1,
async (message: Message) => {
throw new Error();
}
);

@@ -69,5 +83,12 @@ const msg = amqplib.__createMessage({});

let called = false;
await worker.consume(conn, "ping", 1, async (message: Message) => {
called = true;
});
await worker.consume(
conn,
"ping",
"routingKey",
"queueName",
1,
async (message: Message) => {
called = true;
}
);

@@ -84,5 +105,12 @@ const msg = amqplib.__createMessage({});

let called = false;
await worker.consume(conn, "ping", 1, async (message: Message) => {
called = true;
});
await worker.consume(
conn,
"ping",
"routingKey",
"queueName",
1,
async (message: Message) => {
called = true;
}
);

@@ -124,6 +152,13 @@ await ch.sendToQueue("ping", null);

const ch = await worker.consume(conn, "test", 5, async () => {
await sleep(1000);
throw new PermanentWorkerError();
});
const ch = await worker.consume(
conn,
"ping",
"routingKey",
"queueName",
5,
async () => {
await sleep(1000);
throw new PermanentWorkerError();
}
);

@@ -150,6 +185,13 @@ const task = ch.sendToQueue("test", Buffer.from(JSON.stringify({})), {

const ch = await worker.consume(conn, "test", 5, async () => {
await sleep(1000);
throw new Error();
});
const ch = await worker.consume(
conn,
"ping",
"routingKey",
"queueName",
5,
async () => {
await sleep(1000);
throw new Error();
}
);

@@ -176,5 +218,12 @@ const task = ch.sendToQueue("test", Buffer.from(JSON.stringify({})), {

const ch = await worker.consume(conn, "test", 5, async () => {
await sleep(1000);
});
const ch = await worker.consume(
conn,
"ping",
"routingKey",
"queueName",
5,
async () => {
await sleep(1000);
}
);

@@ -196,32 +245,35 @@ const task = ch.sendToQueue("test", Buffer.from(JSON.stringify({})), {

test(
"closes on timeout",
async () => {
const conn: any = amqplib.__queueConnection();
conn.__queueChannel();
test("closes on timeout", async () => {
const conn: any = amqplib.__queueConnection();
conn.__queueChannel();
const proc = mockNodeJSProcess();
const httpServer = mockHttpServer();
const proc = mockNodeJSProcess();
const httpServer = mockHttpServer();
try {
const ch = await worker.consume(conn, "sleep", 5, async () => {
try {
const ch = await worker.consume(
conn,
"ping",
"routingKey",
"queueName",
5,
async () => {
await sleep(5000);
});
}
);
const msg = amqplib.__createMessage({});
const task = ch.sendToQueue("sleep", msg);
const msg = amqplib.__createMessage({});
const task = ch.sendToQueue("sleep", msg);
const handler = worker.terminateHandler(httpServer, proc, 1)();
const handler = worker.terminateHandler(httpServer, proc, 1)();
await handler;
await task;
} catch (err) {
// omit
}
await handler;
await task;
} catch (err) {
// omit
}
expect(proc.exit.mock.calls.length).toBe(1);
},
10000
);
// expect(proc.exit.mock.calls.length).toBe(1);
}, 10000);
});
});

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

/// <reference types="node" />
import * as amqplib from "amqplib";

@@ -3,0 +2,0 @@ import * as http from "http";

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