Comparing version 0.0.2 to 0.0.3
@@ -12,5 +12,5 @@ "use strict"; | ||
instance:{ | ||
instance: { | ||
constructor:function (name, exchange) { | ||
constructor: function (name, exchange) { | ||
this._super(arguments); | ||
@@ -21,3 +21,3 @@ this._exchange = exchange; | ||
publish:function (routingKey, message, opts) { | ||
publish: function (routingKey, message, opts) { | ||
if (!message && routingKey) { | ||
@@ -40,5 +40,5 @@ message = routingKey; | ||
return comb.define([_Options, _GetConnection], { | ||
instance:{ | ||
instance: { | ||
constructor:function Exchange(name, getConnectionCb) { | ||
constructor: function Exchange(name) { | ||
this._super(arguments); | ||
@@ -49,3 +49,3 @@ this.__exchange = null; | ||
__createExchange:function __createExchange() { | ||
__createExchange: function __createExchange() { | ||
var exchangeName = this.exchangeName; | ||
@@ -65,8 +65,8 @@ var ret = this.__exchange || this.getConnection().chain(function connectCb(connection) { | ||
queue:function (name) { | ||
queue: function (name) { | ||
return new ExchangeQueue(name, this, this.__createExchange.bind(this)); | ||
}, | ||
getters:{ | ||
exchange:function () { | ||
getters: { | ||
exchange: function () { | ||
return this.__createExchange().chain(function () { | ||
@@ -79,5 +79,5 @@ return this.__exchange; | ||
"static":{ | ||
OPTIONS:["type", "passive", "durable", "comfirm", "autoDelete", "noDeclare", "confirm"] | ||
"static": { | ||
OPTIONS: ["type", "passive", "durable", "comfirm", "autoDelete", "noDeclare", "confirm"] | ||
} | ||
}).as(module); |
@@ -58,9 +58,2 @@ "use strict"; | ||
function end() { | ||
return connect().chain(function (connection) { | ||
connection.end(); | ||
}); | ||
} | ||
var Hare = comb.define(_Options, { | ||
@@ -72,2 +65,7 @@ | ||
constructor: function () { | ||
this._super(arguments); | ||
this._url = {}; | ||
}, | ||
url: function (url) { | ||
@@ -77,3 +75,3 @@ if (isHash(url)) { | ||
} else { | ||
this._url = {url: url}; | ||
this._url.url = url; | ||
} | ||
@@ -83,12 +81,7 @@ return this; | ||
"set": function set(opt, value) { | ||
var options = this._options; | ||
var opts = options.options || (options.options = {}); | ||
opts[opt] = value; | ||
heartbeat: function (heartbeat) { | ||
this._url.heartbeat = heartbeat; | ||
return this; | ||
}, | ||
"get": function get(opt) { | ||
return this._options.options[opt]; | ||
}, | ||
@@ -165,3 +158,3 @@ connect: function () { | ||
comb.logger.configure(); | ||
} | ||
}; | ||
@@ -168,0 +161,0 @@ hare.noLog = function noLog() { |
@@ -84,3 +84,2 @@ "use strict"; | ||
subscribe: function subscribe(listener) { | ||
var queueName = this.queueName; | ||
return this.__getQueue().chain(function getQueueCb(queue) { | ||
@@ -87,0 +86,0 @@ this.__subscribe(queue, listener); |
{ | ||
"name": "hare", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Wrapper around amqp to make common patterns easier", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "make test" | ||
"test": "it -r dot" | ||
}, | ||
@@ -17,8 +17,10 @@ "repository": { | ||
"amqp": "~0.1.3", | ||
"comb": "~0.2.0" | ||
"comb": "~0.2.0", | ||
"grunt": "~0.4.1" | ||
}, | ||
"devDependencies": { | ||
"it": "0.0.5" | ||
"it": "~0.2.6", | ||
"grunt-it": "~0.3.1", | ||
"grunt-contrib-jshint": "~0.5.4" | ||
} | ||
} |
@@ -1,6 +0,8 @@ | ||
#Hare | ||
[](https://travis-ci.org/C2FO/hare) | ||
# Hare | ||
Hare is a wrapper around [amqp](https://github.com/postwait/node-amqp) providing a cleaner chainable API for some of the common patterns. | ||
##Installation | ||
## Installation | ||
@@ -12,3 +14,3 @@ ``` | ||
##Connecting | ||
## Connecting | ||
@@ -31,4 +33,16 @@ To connect to your `amqp` server you can pass in your options to `hare` | ||
##WorkerQueues | ||
### Heartbeat | ||
You may also specify a heartbeat ([See here](http://www.rabbitmq.com/reliability.html)) | ||
``` | ||
hare({url : "amqp://guest:guest@localhost:5672", heartbeat: 2}); | ||
//or | ||
hare({url : "amqp://guest:guest@localhost:5672"}).heartbeat(2); | ||
``` | ||
## WorkerQueues | ||
Worker queues allow you to ditribute messages to workers, where only one worker will recieve the message. Allowing for the distribution of resource intensive tasks across a worker pool. | ||
@@ -57,3 +71,3 @@ | ||
##Publish/Subscribe | ||
## Publish/Subscribe | ||
@@ -82,3 +96,3 @@ Publish and Subscribe allows you to broadcast messages to multiple consumers at a time. | ||
##Routing | ||
## Routing | ||
@@ -113,3 +127,3 @@ | ||
##Topics | ||
## Topics | ||
@@ -152,3 +166,3 @@ Topics is similar to routing except that it allows you to subscribe to messages on multiple criteria. | ||
##Creating your own Queue | ||
## Creating your own Queue | ||
@@ -183,3 +197,3 @@ You may also use the `queue` method to create your own queue if the above patterns do not match your needs. | ||
##Creating Exchanges | ||
## Creating Exchanges | ||
@@ -208,3 +222,3 @@ You may also use the `exchange` method to work with your own exchange. | ||
##Logging | ||
## Logging | ||
@@ -233,3 +247,3 @@ `Hare` comes with a logger which is useful for debugging. By default logging is turned off. | ||
##Configuring Defaults | ||
## Configuring Defaults | ||
@@ -242,3 +256,3 @@ You can configure defaults for all queues using the `queueOptions` options. | ||
##License | ||
## License | ||
@@ -248,3 +262,3 @@ | ||
##Meta | ||
## Meta | ||
@@ -251,0 +265,0 @@ * Code: `git clone git://github.com/c2fo/hare.git` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
34099
19
709
257
3
3
+ Addedgrunt@~0.4.1
+ Addedabbrev@1.1.1(transitive)
+ Addedargparse@0.1.16(transitive)
+ Addedasync@0.1.22(transitive)
+ Addedcoffee-script@1.3.3(transitive)
+ Addedcolors@0.6.2(transitive)
+ Addeddateformat@1.0.2-1.2.3(transitive)
+ Addedesprima@1.0.4(transitive)
+ Addedeventemitter2@0.4.14(transitive)
+ Addedexit@0.1.2(transitive)
+ Addedfindup-sync@0.1.3(transitive)
+ Addedgetobject@0.1.0(transitive)
+ Addedglob@3.1.213.2.11(transitive)
+ Addedgraceful-fs@1.2.3(transitive)
+ Addedgrunt@0.4.5(transitive)
+ Addedgrunt-legacy-log@0.1.3(transitive)
+ Addedgrunt-legacy-log-utils@0.1.1(transitive)
+ Addedgrunt-legacy-util@0.2.0(transitive)
+ Addedhooker@0.2.3(transitive)
+ Addediconv-lite@0.2.11(transitive)
+ Addedinherits@1.0.22.0.4(transitive)
+ Addedjs-yaml@2.0.5(transitive)
+ Addedlodash@0.9.22.4.2(transitive)
+ Addedlru-cache@2.7.3(transitive)
+ Addedminimatch@0.2.140.3.0(transitive)
+ Addednopt@1.0.10(transitive)
+ Addedrimraf@2.2.8(transitive)
+ Addedsigmund@1.0.1(transitive)
+ Addedunderscore@1.7.0(transitive)
+ Addedunderscore.string@2.2.12.3.32.4.0(transitive)
+ Addedwhich@1.0.9(transitive)