rabbit-queue
Advanced tools
Comparing version 4.0.0 to 4.1.0
@@ -1,2 +0,1 @@ | ||
/// <reference types="amqplib" /> | ||
import Rabbit from './rabbit'; | ||
@@ -17,3 +16,3 @@ import * as amqp from 'amqplib'; | ||
}; | ||
constructor(queueName: any, rabbit: Rabbit, {retries, retryDelay, logEnabled, scope, createAndSubscribeToQueue}?: { | ||
constructor(queueName: any, rabbit: Rabbit, { retries, retryDelay, logEnabled, scope, createAndSubscribeToQueue }?: { | ||
retries?: number; | ||
@@ -31,7 +30,7 @@ retryDelay?: number; | ||
createQueues(): void; | ||
tryHandle(retries: any, msg: amqp.Message, ack: (error, reply) => any): Promise<void>; | ||
tryHandle(retries: any, msg: amqp.Message, ack: (error: any, reply: any) => any): Promise<void>; | ||
handleError(err: any, msg: any): void; | ||
getTime(): number; | ||
logTime(startTime: number, correlationId: string): void; | ||
setTimeout(time: any): Promise<{}>; | ||
setTimeout(time: any): Promise<unknown>; | ||
retry(retries: any, msg: any, ack: any): Promise<void>; | ||
@@ -38,0 +37,0 @@ abstract handle(data: { |
@@ -1,2 +0,2 @@ | ||
/// <reference types="amqplib" /> | ||
/// <reference types="node" /> | ||
import * as amqp from 'amqplib'; | ||
@@ -3,0 +3,0 @@ export interface Channel extends amqp.Channel { |
@@ -1,2 +0,1 @@ | ||
/// <reference types="amqplib" /> | ||
import { Channel } from './channel'; | ||
@@ -3,0 +2,0 @@ import * as amqp from 'amqplib'; |
@@ -15,4 +15,6 @@ "use strict"; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) | ||
t[p[i]] = s[p[i]]; | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
@@ -19,0 +21,0 @@ }; |
@@ -0,2 +1,3 @@ | ||
/// <reference types="node" /> | ||
export declare function encode(message?: Buffer | string | Object, contentType?: string): Buffer; | ||
export declare function decode(msg: any): any; |
@@ -1,2 +0,1 @@ | ||
/// <reference types="amqplib" /> | ||
import * as amqp from 'amqplib'; | ||
@@ -8,5 +7,5 @@ import { Channel } from './channel'; | ||
}; | ||
publish(channel: Channel, exchange: string, routingKey: string, content: any, properties?: amqp.Options.Publish): Promise<{}>; | ||
publish(channel: Channel, exchange: string, routingKey: string, content: any, properties?: amqp.Options.Publish): Promise<unknown>; | ||
getReply(channel: Channel, exchange: string, routingKey: string, content: any, properties: amqp.Options.Publish, timeout?: number): Promise<any>; | ||
}; | ||
export default _default; |
@@ -1,2 +0,1 @@ | ||
/// <reference types="amqplib" /> | ||
import * as amqp from 'amqplib'; | ||
@@ -24,3 +23,3 @@ import { Channel } from './channel'; | ||
create(): Promise<void>; | ||
subscribe(handler: (msg: any, ack: (error?, reply?) => any) => any): Promise<void>; | ||
subscribe(handler: (msg: any, ack: (error?: any, reply?: any) => any) => any): Promise<void>; | ||
unsubscribe(): Promise<void>; | ||
@@ -30,3 +29,3 @@ static destroy(channel: Channel, name: string): Promise<void>; | ||
onMessage(msg: amqp.Message): void; | ||
static publish(obj: any, properties: amqp.Options.Publish, channel: Channel, name: string, queue?: Queue): Promise<{}>; | ||
static publish(obj: any, properties: amqp.Options.Publish, channel: Channel, name: string, queue?: Queue): Promise<unknown>; | ||
static getReply(obj: any, properties: amqp.Options.Publish, channel: Channel, name: string, queue?: Queue, timeout?: number): Promise<any>; | ||
@@ -33,0 +32,0 @@ static bindToExchange(exchange: string, routingKey: string, channel: Channel, name: string, queue?: Queue): Promise<void>; |
@@ -12,4 +12,6 @@ "use strict"; | ||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); | ||
var m = o[Symbol.asyncIterator]; | ||
return m ? m.call(o) : typeof __values === "function" ? __values(o) : o[Symbol.iterator](); | ||
var m = o[Symbol.asyncIterator], i; | ||
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); | ||
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } | ||
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } | ||
}; | ||
@@ -88,3 +90,4 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
} | ||
this.handler(msg, (error, reply) => __awaiter(this, void 0, void 0, function* () { | ||
this.handler(msg, (error, reply) => { var reply_1, reply_1_1; return __awaiter(this, void 0, void 0, function* () { | ||
var e_1, _a; | ||
const { replyTo, correlationId } = msg.properties; | ||
@@ -100,16 +103,21 @@ if (error && reply !== Queue.STOP_PROPAGATION) { | ||
try { | ||
for (var reply_1 = __asyncValues(reply), reply_1_1; reply_1_1 = yield reply_1.next(), !reply_1_1.done;) { | ||
const chunk = yield reply_1_1.value; | ||
const replyBuffer = encode_decode_1.encode(chunk.toString()); | ||
this.channel.sendToQueue(replyTo, replyBuffer, properties); | ||
} | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (reply_1_1 && !reply_1_1.done && (_a = reply_1.return)) yield _a.call(reply_1); | ||
for (reply_1 = __asyncValues(reply); reply_1_1 = yield reply_1.next(), !reply_1_1.done;) { | ||
const chunk = reply_1_1.value; | ||
const replyBuffer = encode_decode_1.encode(chunk.toString()); | ||
this.channel.sendToQueue(replyTo, replyBuffer, properties); | ||
} | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (reply_1_1 && !reply_1_1.done && (_a = reply_1.return)) yield _a.call(reply_1); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
this.channel.sendToQueue(replyTo, encode_decode_1.encode(null), properties, ack); | ||
} | ||
this.channel.sendToQueue(replyTo, encode_decode_1.encode(null), properties, ack); | ||
catch (e) { | ||
this.channel.sendToQueue(replyTo, encode_decode_1.encode(Object.assign({}, Queue.ERROR_DURING_REPLY, { error_message: e.message })), properties, ack); | ||
} | ||
} | ||
@@ -119,4 +127,3 @@ else { | ||
} | ||
var e_1, _a; | ||
})); | ||
}); }); | ||
} | ||
@@ -123,0 +130,0 @@ static publish(obj, properties = {}, channel, name, queue) { |
@@ -1,2 +0,2 @@ | ||
/// <reference types="amqplib" /> | ||
/// <reference types="node" /> | ||
import * as amqp from 'amqplib'; | ||
@@ -23,3 +23,3 @@ import { EventEmitter } from 'events'; | ||
socketOptions: any; | ||
constructor(url: string, {prefetch, replyPattern, prefix, scheduledPublish, socketOptions}?: { | ||
constructor(url: string, { prefetch, replyPattern, prefix, scheduledPublish, socketOptions }?: { | ||
prefetch?: number; | ||
@@ -31,13 +31,13 @@ replyPattern?: boolean; | ||
}); | ||
private connect(); | ||
private connect; | ||
reconnect(): Promise<void>; | ||
private emitDisconnected(error); | ||
private emitDisconnected; | ||
createChannel(connection: amqp.Connection): Promise<amqp.Channel>; | ||
initChannel(channel: Channel): Promise<void>; | ||
private updateName(name, prefix?); | ||
private updateName; | ||
createQueue(name: string, options?: amqp.Options.AssertQueue & { | ||
prefix?: string; | ||
}, handler?: (msg: any, ack: (error?, reply?) => any) => any): Promise<Queue>; | ||
}, handler?: (msg: any, ack: (error?: any, reply?: any) => any) => any): Promise<Queue>; | ||
destroyQueue(name: string, prefix?: string): Promise<void>; | ||
subscribe(name: any, handler: (msg: any, ack: (reply) => any) => any, prefix?: string): Promise<void>; | ||
subscribe(name: any, handler: (msg: any, ack: (reply: any) => any) => any, prefix?: string): Promise<void>; | ||
unsubscribe(name: any, prefix?: string): Promise<void>; | ||
@@ -44,0 +44,0 @@ publish(name: string, obj: any, headers?: amqp.Options.Publish, prefix?: string): Promise<void>; |
@@ -1,2 +0,1 @@ | ||
/// <reference types="amqplib" /> | ||
import { Channel } from './channel'; | ||
@@ -6,2 +5,2 @@ import * as amqp from 'amqplib'; | ||
export declare function addHandler(correlationId: any, handler: (err: Error, body: string) => void): void; | ||
export declare function getReply(content: any, properties: amqp.Options.Publish, channel: Channel, cb: Function): Promise<{}>; | ||
export declare function getReply(content: any, properties: amqp.Options.Publish, channel: Channel, cb: Function): Promise<unknown>; |
@@ -88,2 +88,6 @@ "use strict"; | ||
const obj = encode_decode_1.decode(msg); | ||
if (obj && obj.error && obj.error_code === queue_1.default.ERROR_DURING_REPLY.error_code) { | ||
delete streamHandlers[id]; | ||
return streamHandler.emit('error', new Error(obj.error_message)); | ||
} | ||
logger.info(`[${id}] <- Returning${obj === null && ' the end of'} stream reply ${msg.content.byteLength} bytes`); | ||
@@ -90,0 +94,0 @@ streamHandler.push(obj); |
{ | ||
"name": "rabbit-queue", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"description": "AMQP/RabbitMQ queue management library.", | ||
@@ -67,3 +67,3 @@ "main": "js/index.js", | ||
"@types/node-uuid": "0.0.28", | ||
"@types/should": "8.1.30", | ||
"@types/should": "13.0.0", | ||
"@types/sinon": "1.16.30", | ||
@@ -76,4 +76,3 @@ "@types/source-map-support": "0.2.28", | ||
"nyc": "^14.1.1", | ||
"remap-istanbul": "^0.11.1", | ||
"should": "10.0.0", | ||
"should": "13.2.3", | ||
"sinon": "1.17.5", | ||
@@ -83,4 +82,4 @@ "source-map-support": "^0.4.18", | ||
"tslint": "5.18.0", | ||
"typescript": "2.8.3" | ||
"typescript": "3.5.3" | ||
} | ||
} |
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
104894
18
1290