mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-03 03:31:47 +00:00
Update bunnymq definition (2.3.2).
This commit is contained in:
@@ -4,31 +4,20 @@ import * as bunnymq from "bunnymq";
|
||||
var instance = bunnymq({ host: 'amqp://localhost' });
|
||||
|
||||
// Publisher
|
||||
instance.producer.produce('queue:name', 'Hello World!');
|
||||
instance.publish("queue:name", "message");
|
||||
// Subscriber
|
||||
instance.consumer.consume('queue:name', message => { });
|
||||
instance.subscribe('queue:name', (message: string) => "hello,world");
|
||||
|
||||
// RPC Support
|
||||
instance.producer.produce('queue:name', { message: 'content' }, { rpc: true })
|
||||
.then(function (consumerResponse) {
|
||||
console.log(consumerResponse);
|
||||
});
|
||||
|
||||
// Routing keys
|
||||
instance.producer.produce('queue:name', { message: 'content' }, { routingKey: 'my-routing-key' });
|
||||
instance.publish('queue:name', { message: 'content' }, { routingKey: 'my-routing-key', rpc: true }).then((consumerResponse: string) => { });
|
||||
|
||||
// Config
|
||||
var custom = bunnymq({
|
||||
host: 'amqp://localhost',
|
||||
//number of fetched messages at once on the channel
|
||||
prefetch: 5,
|
||||
//requeue put back message into the broker if consumer crashes/trigger exception
|
||||
requeue: true,
|
||||
//time between two reconnect (ms)
|
||||
timeout: 1000,
|
||||
consumerSuffix: '',
|
||||
//generate a hostname so we can track this connection on the broker (rabbitmq management plugin)
|
||||
consumerSuffix: "",
|
||||
hostname: "",
|
||||
//the transport to use to debug. if provided, bunnymq will show some logs
|
||||
transport: new Object()
|
||||
});
|
||||
});
|
||||
|
||||
Vendored
+11
-34
@@ -1,25 +1,10 @@
|
||||
// Type definitions for node-bunnymq 2.2.1
|
||||
// Type definitions for node-bunnymq 2.3.2
|
||||
// Project: https://github.com/dial-once/node-bunnymq
|
||||
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module "bunnymq" {
|
||||
namespace bunnymq {
|
||||
export type ConsumerCallback = (message: Object) => void;
|
||||
|
||||
/**
|
||||
* Consumer.
|
||||
* @interface
|
||||
*/
|
||||
export interface Consumer {
|
||||
/**
|
||||
* Handle messages from a named queue.
|
||||
* @param {string} queue A named queue.
|
||||
* @param {ConsumerCallback} callback A callback.
|
||||
*/
|
||||
consume(queue: string, callback: ConsumerCallback): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* bunnymq instance.
|
||||
* @interface
|
||||
@@ -29,13 +14,13 @@ declare module "bunnymq" {
|
||||
* Consumer.
|
||||
* @type {Consumer}
|
||||
*/
|
||||
consumer: Consumer;
|
||||
subscribe<T>(queueName: string, callback: (...args: any[]) => T): void;
|
||||
|
||||
/**
|
||||
* Producer.
|
||||
* @type {Producer}
|
||||
*/
|
||||
producer: Producer;
|
||||
publish<T>(queueName: string, message: any, options?: PublisherOptions): Promise<T>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,6 +58,12 @@ declare module "bunnymq" {
|
||||
*/
|
||||
requeue?: boolean;
|
||||
|
||||
/**
|
||||
* Default timeout for RPC calls.
|
||||
* @type {number}
|
||||
*/
|
||||
rpcTimeout?: number;
|
||||
|
||||
/**
|
||||
* Time between two reconnect (in milliseconds).
|
||||
* @type {number}
|
||||
@@ -87,24 +78,10 @@ declare module "bunnymq" {
|
||||
}
|
||||
|
||||
/**
|
||||
* Producer.
|
||||
* @inteface
|
||||
*/
|
||||
export interface Producer {
|
||||
/**
|
||||
* Send messages to a named queue.
|
||||
* @param {string} queue A named queue.
|
||||
* @param {Object} message A message.
|
||||
* @return {Object} The consumer response.
|
||||
*/
|
||||
produce(queue: string, message: Object, options?: ProducerOptions): PromiseLike<Object>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for producer.
|
||||
* Options for publisher.
|
||||
* @interface
|
||||
*/
|
||||
export interface ProducerOptions {
|
||||
export interface PublisherOptions {
|
||||
routingKey?: string;
|
||||
rpc?: boolean;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user