Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Full API support and documentation #4

Merged
merged 6 commits into from

2 participants

Commits on Mar 26, 2013
  1. @featalion

    full api support

    featalion authored
  2. @featalion

    adds documentation

    featalion authored
  3. @featalion

    bump version (0.2.0)

    featalion authored
  4. @featalion
Commits on Mar 27, 2013
  1. @featalion

    fix lib for new node version

    featalion authored
  2. @featalion

    update dependencies

    featalion authored
This page is out of date. Refresh to see the latest.
View
266 README.md
@@ -1,2 +1,264 @@
-iron_mq_node
-============
+IronMQ Node.js Client
+-------------
+
+The [full API documentation is here](http://dev.iron.io/mq/reference/api/) and this client tries to stick to the API as
+much as possible so if you see an option in the API docs, you can use it in the methods below.
+
+
+## Getting Started
+
+1\. Install the gem:
+
+```
+npm install iron_mq
+```
+
+2\. [Setup your Iron.io credentials](http://dev.iron.io/mq/reference/configuration/)
+
+3\. Create an IronMQ Client object:
+
+```javascript
+var iron_mq = require('iron_mq');
+var imq = new iron_mq.Client();
+```
+
+Or pass in credentials:
+
+```javascript
+var imq = new iron_mq.Client({token: "MY_TOKEN", project_id: "MY_PROJECT_ID"});
+```
+
+
+## Usage
+
+### Get Queues List
+
+```javascript
+imq.queues(options, callback(error, body) {});
+```
+
+**Options:**
+
+* `page`: The 0-based page to view. The default is 0.
+* `per_page`: The number of queues to return per page. The default is 30, the maximum is 100.
+
+--
+
+### Get a Queue Object
+
+You can have as many queues as you want, each with their own unique set of messages.
+
+```javascript
+imq.queue("my_queue", callback(error, body) {});
+```
+
+**Note:** if queue with desired name does not exist it returns fake queue.
+Queue will be created automatically on post of first message or queue configuration update.
+
+--
+
+### Retrieve Queue Information
+
+```javascript
+queue.info(callback(error, body) {});
+```
+
+--
+
+### Post a Message on a Queue
+
+Messages are placed on the queue in a FIFO arrangement.
+If a queue does not exist, it will be created upon the first posting of a message.
+
+```javascript
+queue.post(messages, callback(error, body) {});
+
+// single message
+queue.post("hello IronMQ!", callback(error, body) {});
+// with options
+queue.post({body: "hello IronMQ", delay: 30}, callback(error, body) {});
+// or multiple messages
+queue.post(["hello", "IronMQ"], callback(error, body) {});
+// messages with options
+queue.post(
+ [{body: "hello", timeout: 40},
+ {body: "IronMQ", timeout: 80}],
+ callback(error, body) {}
+);
+```
+
+**Optional messages' parameters:**
+
+* `timeout`: After timeout (in seconds), item will be placed back onto queue.
+You must delete the message from the queue to ensure it does not go back onto the queue.
+ Default is 60 seconds. Minimum is 30 seconds. Maximum is 86,400 seconds (24 hours).
+
+* `delay`: The item will not be available on the queue until this many seconds have passed.
+Default is 0 seconds. Maximum is 604,800 seconds (7 days).
+
+* `expires_in`: How long in seconds to keep the item on the queue before it is deleted.
+Default is 604,800 seconds (7 days). Maximum is 2,592,000 seconds (30 days).
+
+--
+
+### Get a Messages off a Queue
+
+```javascript
+queue.get(options, callback(error, body) {});
+```
+
+**Options:**
+
+* `n`: The maximum number of messages to get. Default is 1. Maximum is 100.
+
+* `timeout`: After timeout (in seconds), item will be placed back onto queue.
+You must delete the message from the queue to ensure it does not go back onto the queue.
+If not set, value from POST is used. Default is 60 seconds. Minimum is 30 seconds.
+Maximum is 86,400 seconds (24 hours).
+
+When `n` parameter is specified and greater than 1 method returns list of messages.
+Otherwise, message's object will be returned.
+
+When you pop/get a message from the queue, it is no longer on the queue but it still exists within the system.
+You have to explicitly delete the message or else it will go back onto the queue after the `timeout`.
+
+--
+
+### Touch a Message on a Queue
+
+Touching a reserved message extends its timeout by the duration specified when the message was created, which is 60 seconds by default.
+
+```javascript
+queue.touch(message_id, callback(error, body) {});
+```
+
+--
+
+### Release Message
+
+```javascript
+queue.release(message_id, options, callback(error, body) {});
+```
+
+**Options:**
+
+* `delay`: The item will not be available on the queue until this many seconds have passed.
+Default is 0 seconds. Maximum is 604,800 seconds (7 days).
+
+--
+
+### Delete a Message from a Queue
+
+```javascript
+queue.delete(message_id, callback(error, body) {});
+```
+
+Be sure to delete a message from the queue when you're done with it.
+
+--
+
+### Clear a Queue
+
+```javascript
+queue.clear(callback(error, body) {});
+```
+
+--
+
+### Delete a Message Queue
+
+```javascript
+queue.del_queue(callback(error, body) {});
+```
+
+--
+
+## Push Queues
+
+IronMQ push queues allow you to setup a queue that will push to an endpoint, rather than having to poll the endpoint.
+[Here's the announcement for an overview](http://blog.iron.io/2013/01/ironmq-push-queues-reliable-message.html).
+
+### Update a Message Queue
+
+```javascript
+queue.update(options, callback(error, body) {});
+```
+
+**The following options are all related to Push Queues:**
+
+* `subscribers`: An array of subscriber hashes containing a “url” field.
+This set of subscribers will replace the existing subscribers.
+To add or remove subscribers, see the add subscribers endpoint or the remove subscribers endpoint.
+See below for example json.
+* `push_type`: Either `multicast` to push to all subscribers or `unicast` to push to one and only one subscriber. Default is `multicast`.
+* `retries`: How many times to retry on failure. Default is 3.
+* `retries_delay`: Delay between each retry in seconds. Default is 60.
+
+**Example:**
+
+```javascript
+queue.update(
+ {push_type: "multicast",
+ retries: 5,
+ subscribers: [
+ {url: "http://my.first.end.point/push"},
+ {url: "http://my.second.end.point/push"}
+ ]},
+ callback(error, body) {}
+);
+```
+
+--
+
+### Add/Remove Subscribers on a Queue
+
+```javascript
+queue.add_subscribers({url: "http://nowhere.com"}, callback(error, body) {});
+
+queue.add_subscribers(
+ [{url: 'http://first.endpoint.xx/process'},
+ {url: 'http://second.endpoint.xx/process'}],
+ callback(error, body) {}
+);
+
+
+queue.rm_subscribers({url: "http://nowhere.com"}, callback(error, body) {});
+
+queue.rm_subscribers(
+ [{url: 'http://first.endpoint.xx/process'},
+ {url: 'http://second.endpoint.xx/process'}],
+ callback(error, body) {}
+);
+```
+
+--
+
+### Get Message Push Status
+
+After pushing a message:
+
+```javascript
+queue.msg_push_statuses(message_id, callback(error, body) {});
+```
+
+--
+
+### Acknowledge / Delete Message Push Status
+
+```javascript
+queue.del_msg_push_status(message_id, subscriber_id, callback(error, body) {});
+```
+
+--
+
+
+## Further Links
+
+* [IronMQ Overview](http://dev.iron.io/mq/)
+* [IronMQ REST/HTTP API](http://dev.iron.io/mq/reference/api/)
+* [Push Queues](http://dev.iron.io/mq/reference/push_queues/)
+* [Other Client Libraries](http://dev.iron.io/mq/libraries/)
+* [Live Chat, Support & Fun](http://get.iron.io/chat)
+
+-------------
+© 2011 - 2013 Iron.io Inc. All Rights Reserved.
View
107 lib/api_client.js
@@ -1,4 +1,4 @@
-// Generated by CoffeeScript 1.3.3
+// Generated by CoffeeScript 1.6.2
(function() {
var APIClient, ironCore, version, _,
__hasProp = {}.hasOwnProperty,
@@ -13,7 +13,6 @@
ironCore = require('iron_core');
APIClient = (function(_super) {
-
__extends(APIClient, _super);
APIClient.prototype.AWS_US_EAST_HOST = 'mq-aws-us-east-1.iron.io';
@@ -22,12 +21,13 @@
function APIClient(options) {
var defaultOptions;
+
defaultOptions = {
scheme: 'https',
host: this.AWS_US_EAST_HOST,
port: 443,
api_version: 1,
- user_agent: this.version,
+ user_agent: version,
queue_name: 'default'
};
APIClient.__super__.constructor.call(this, 'iron', 'mq', options, defaultOptions, ['project_id', 'token', 'api_version', 'queue_name']);
@@ -38,7 +38,7 @@
};
APIClient.prototype.url = function() {
- return APIClient.__super__.url.call(this) + this.options.api_version.toString() + '/';
+ return APIClient.__super__.url.call(this) + this.options.api_version.toString() + ("/projects/" + this.options.project_id + "/queues");
};
APIClient.prototype.headers = function() {
@@ -49,32 +49,72 @@
APIClient.prototype.queuesList = function(options, cb) {
var parseResponseBind;
+
parseResponseBind = _.bind(this.parseResponse, this);
- return this.get("projects/" + this.options.project_id + "/queues", options, function(error, response, body) {
+ return this.get("", options, function(error, response, body) {
return parseResponseBind(error, response, body, cb);
});
};
APIClient.prototype.queuesGet = function(queue_name, cb) {
var parseResponseBind;
+
parseResponseBind = _.bind(this.parseResponse, this);
- return this.get("projects/" + this.options.project_id + "/queues/" + queue_name, {}, function(error, response, body) {
+ return this.get("/" + queue_name, {}, function(error, response, body) {
return parseResponseBind(error, response, body, cb);
});
};
APIClient.prototype.queuesClear = function(queue_name, cb) {
var parseResponseBind;
+
+ parseResponseBind = _.bind(this.parseResponse, this);
+ return this.post("/" + queue_name + "/clear", {}, function(error, response, body) {
+ return parseResponseBind(error, response, body, cb);
+ });
+ };
+
+ APIClient.prototype.queuesUpdate = function(queue_name, options, cb) {
+ var parseResponseBind;
+
+ parseResponseBind = _.bind(this.parseResponse, this);
+ return this.post("/" + queue_name, options, function(error, response, body) {
+ return parseResponseBind(error, response, body, cb);
+ });
+ };
+
+ APIClient.prototype.queuesAddSubscribers = function(queue_name, subscribers, cb) {
+ var parseResponseBind;
+
+ parseResponseBind = _.bind(this.parseResponse, this);
+ return this.post("/" + queue_name + "/subscribers", subscribers, function(error, response, body) {
+ return parseResponseBind(error, response, body, cb);
+ });
+ };
+
+ APIClient.prototype.queuesRemoveSubscribers = function(queue_name, subscribers, cb) {
+ var parseResponseBind;
+
+ parseResponseBind = _.bind(this.parseResponse, this);
+ return this["delete"]("/" + queue_name + "/subscribers", subscribers, function(error, response, body) {
+ return parseResponseBind(error, response, body, cb);
+ });
+ };
+
+ APIClient.prototype.queuesDelete = function(queue_name, cb) {
+ var parseResponseBind;
+
parseResponseBind = _.bind(this.parseResponse, this);
- return this.post("projects/" + this.options.project_id + "/queues/" + queue_name + "/clear", {}, function(error, response, body) {
+ return this["delete"]("/" + queue_name, {}, function(error, response, body) {
return parseResponseBind(error, response, body, cb);
});
};
APIClient.prototype.messagesPost = function(queue_name, messages, cb) {
var parseResponseBind;
+
parseResponseBind = _.bind(this.parseResponse, this);
- return this.post("projects/" + this.options.project_id + "/queues/" + queue_name + "/messages", {
+ return this.post("/" + queue_name + "/messages", {
messages: messages
}, function(error, response, body) {
return parseResponseBind(error, response, body, cb);
@@ -83,16 +123,63 @@
APIClient.prototype.messagesGet = function(queue_name, options, cb) {
var parseResponseBind;
+
parseResponseBind = _.bind(this.parseResponse, this);
- return this.get("projects/" + this.options.project_id + "/queues/" + queue_name + "/messages", options, function(error, response, body) {
+ return this.get("/" + queue_name + "/messages", options, function(error, response, body) {
return parseResponseBind(error, response, body, cb);
});
};
APIClient.prototype.messagesDelete = function(queue_name, message_id, cb) {
var parseResponseBind;
+
+ parseResponseBind = _.bind(this.parseResponse, this);
+ return this["delete"]("/" + queue_name + "/messages/" + message_id, {}, function(error, response, body) {
+ return parseResponseBind(error, response, body, cb);
+ });
+ };
+
+ APIClient.prototype.messagesPeek = function(queue_name, options, cb) {
+ var parseResponseBind;
+
+ parseResponseBind = _.bind(this.parseResponse, this);
+ return this.get("/" + queue_name + "/messages/peek", options, function(error, response, body) {
+ return parseResponseBind(error, response, body, cb);
+ });
+ };
+
+ APIClient.prototype.messagesTouch = function(queue_name, message_id, cb) {
+ var parseResponseBind;
+
+ parseResponseBind = _.bind(this.parseResponse, this);
+ return this.post("/" + queue_name + "/messages/" + message_id + "/touch", {}, function(error, response, body) {
+ return parseResponseBind(error, response, body, cb);
+ });
+ };
+
+ APIClient.prototype.messagesRelease = function(queue_name, message_id, options, cb) {
+ var parseResponseBind;
+
+ parseResponseBind = _.bind(this.parseResponse, this);
+ return this.post("/" + queue_name + "/messages/" + message_id + "/release", options, function(error, response, body) {
+ return parseResponseBind(error, response, body, cb);
+ });
+ };
+
+ APIClient.prototype.messagesPushStatuses = function(queue_name, message_id, cb) {
+ var parseResponseBind;
+
+ parseResponseBind = _.bind(this.parseResponse, this);
+ return this.get("/" + queue_name + "/messages/" + message_id + "/subscribers", {}, function(error, response, body) {
+ return parseResponseBind(error, response, body, cb);
+ });
+ };
+
+ APIClient.prototype.messagesPushStatusDelete = function(queue_name, message_id, subscriber_id, cb) {
+ var parseResponseBind;
+
parseResponseBind = _.bind(this.parseResponse, this);
- return this["delete"]("projects/" + this.options.project_id + "/queues/" + queue_name + "/messages/" + message_id, {}, function(error, response, body) {
+ return this["delete"]("/" + queue_name + "/messages/" + message_id + "/subscribers/" + subscriber_id, {}, function(error, response, body) {
return parseResponseBind(error, response, body, cb);
});
};
View
113 lib/client.js
@@ -1,4 +1,4 @@
-// Generated by CoffeeScript 1.3.3
+// Generated by CoffeeScript 1.6.2
(function() {
var Client, apiClient, _;
@@ -7,7 +7,6 @@
apiClient = require('./api_client');
Client = (function() {
-
function Client(options) {
this.api = new apiClient.APIClient(options);
}
@@ -20,7 +19,7 @@
Client.prototype.queues = function(options, cb) {
return this.api.queuesList(options, function(error, body) {
- if (!(error != null)) {
+ if (error == null) {
return cb(error, body);
} else {
return cb(error, body);
@@ -30,7 +29,7 @@
Client.prototype.info = function(cb) {
return this.api.queuesGet(this.api.options.queue_name, function(error, body) {
- if (!(error != null)) {
+ if (error == null) {
return cb(error, body);
} else {
return cb(error, body);
@@ -40,7 +39,53 @@
Client.prototype.clear = function(cb) {
return this.api.queuesClear(this.api.options.queue_name, function(error, body) {
- if (!(error != null)) {
+ if (error == null) {
+ return cb(error, body);
+ } else {
+ return cb(error, body);
+ }
+ });
+ };
+
+ Client.prototype.update = function(options, cb) {
+ return this.api.queuesUpdate(this.api.options.queue_name, options, function(error, body) {
+ if (error == null) {
+ return cb(error, body);
+ } else {
+ return cb(error, body);
+ }
+ });
+ };
+
+ Client.prototype.add_subscribers = function(subscribers, cb) {
+ if (!(subscribers instanceof Array)) {
+ subscribers = [subscribers];
+ }
+ return this.api.queuesAddSubscribers(this.api.options.queue_name, subscribers, function(error, body) {
+ if (error == null) {
+ return cb(error, body);
+ } else {
+ return cb(error, body);
+ }
+ });
+ };
+
+ Client.prototype.rm_subscribers = function(subscribers, cb) {
+ if (!(subscribers instanceof Array)) {
+ subscribers = [subscribers];
+ }
+ return this.api.queuesRemoveSubscribers(this.api.options.queue_name, subscribers, function(error, body) {
+ if (error == null) {
+ return cb(error, body);
+ } else {
+ return cb(error, body);
+ }
+ });
+ };
+
+ Client.prototype.del_queue = function(cb) {
+ return this.api.queuesDelete(this.api.options.queue_name, function(error, body) {
+ if (error == null) {
return cb(error, body);
} else {
return cb(error, body);
@@ -62,7 +107,7 @@
}
});
return this.api.messagesPost(this.api.options.queue_name, messages, function(error, body) {
- if (!(error != null)) {
+ if (error == null) {
return cb(error, messages.length === 1 ? body.ids[0] : body.ids);
} else {
return cb(error, body);
@@ -72,8 +117,18 @@
Client.prototype.get = function(options, cb) {
return this.api.messagesGet(this.api.options.queue_name, options, function(error, body) {
- if (!(error != null)) {
- return cb(error, (!(options.n != null)) || options.n === 1 ? body.messages[0] : body.messages);
+ if (error == null) {
+ return cb(error, (options.n == null) || options.n === 1 ? body.messages[0] : body.messages);
+ } else {
+ return cb(error, body);
+ }
+ });
+ };
+
+ Client.prototype.peek = function(options, cb) {
+ return this.api.messagesPeek(this.api.options.queue_name, options, function(error, body) {
+ if (error == null) {
+ return cb(error, (options.n == null) || options.n === 1 ? body.messages[0] : body.messages);
} else {
return cb(error, body);
}
@@ -82,7 +137,47 @@
Client.prototype.del = function(message_id, cb) {
return this.api.messagesDelete(this.api.options.queue_name, message_id, function(error, body) {
- if (!(error != null)) {
+ if (error == null) {
+ return cb(error, body);
+ } else {
+ return cb(error, body);
+ }
+ });
+ };
+
+ Client.prototype.msg_touch = function(message_id, cb) {
+ return this.api.messagesTouch(this.api.options.queue_name, message_id, function(error, body) {
+ if (error == null) {
+ return cb(error, body);
+ } else {
+ return cb(error, body);
+ }
+ });
+ };
+
+ Client.prototype.msg_release = function(message_id, options, cb) {
+ return this.api.messagesRelease(this.api.options.queue_name, message_id, options, function(error, body) {
+ if (error == null) {
+ return cb(error, body);
+ } else {
+ return cb(error, body);
+ }
+ });
+ };
+
+ Client.prototype.msg_push_statuses = function(message_id, cb) {
+ return this.api.messagesPushStatuses(this.api.options.queue_name, message_id, function(error, body) {
+ if (error == null) {
+ return cb(error, body);
+ } else {
+ return cb(error, body);
+ }
+ });
+ };
+
+ Client.prototype.del_msg_push_status = function(message_id, subscriber_id, cb) {
+ return this.api.messagesPushStatusDelete(this.api.options.queue_name, message_id, subscriber_id, function(error, body) {
+ if (error == null) {
return cb(error, body);
} else {
return cb(error, body);
View
6 package.json
@@ -1,9 +1,9 @@
{
"name": "iron_mq",
- "version": "0.1.0",
+ "version": "0.2.0",
"description": "Node client for IronMQ",
"homepage": "https://github.com/iron-io/iron_mq_node",
- "author": "Andrew Kirilenko & Iron.io, Inc",
+ "author": "Andrew Kirilenko, Yury Yantsevich & Iron.io, Inc",
"main": "./lib/client",
"dependencies": {
"pkginfo": "0.2.3",
@@ -11,7 +11,7 @@
"iron_core": "0.2"
},
"devDependencies": {
- "coffee-script": "1.3.3"
+ "coffee-script": "1.6.2"
},
"repository": {
"type": "git",
View
81 src/api_client.coffee
@@ -15,7 +15,7 @@ class APIClient extends ironCore.Client
host: @AWS_US_EAST_HOST,
port: 443,
api_version: 1,
- user_agent: @version,
+ user_agent: version,
queue_name: 'default'
super('iron', 'mq', options, defaultOptions, ['project_id', 'token', 'api_version', 'queue_name'])
@@ -24,7 +24,7 @@ class APIClient extends ironCore.Client
"iron_mq_node-#{version} (#{super()})"
url: ->
- super() + @options.api_version.toString() + '/'
+ super() + @options.api_version.toString() + "/projects/#{@options.project_id}/queues"
headers: ->
_.extend({}, super(), {'Authorization': "OAuth #{@options.token}"})
@@ -32,42 +32,105 @@ class APIClient extends ironCore.Client
queuesList: (options, cb) ->
parseResponseBind = _.bind(@parseResponse, @)
- @get("projects/#{@options.project_id}/queues", options, (error, response, body) ->
+ @get("", options, (error, response, body) ->
parseResponseBind(error, response, body, cb)
)
queuesGet: (queue_name, cb) ->
parseResponseBind = _.bind(@parseResponse, @)
- @get("projects/#{@options.project_id}/queues/#{queue_name}", {}, (error, response, body) ->
+ @get("/#{queue_name}", {}, (error, response, body) ->
parseResponseBind(error, response, body, cb)
)
queuesClear: (queue_name, cb) ->
parseResponseBind = _.bind(@parseResponse, @)
- @post("projects/#{@options.project_id}/queues/#{queue_name}/clear", {}, (error, response, body) ->
+ @post("/#{queue_name}/clear", {}, (error, response, body) ->
+ parseResponseBind(error, response, body, cb)
+ )
+
+ queuesUpdate: (queue_name, options, cb) ->
+ parseResponseBind = _.bind(@parseResponse, @)
+
+ @post("/#{queue_name}", options, (error, response, body) ->
+ parseResponseBind(error, response, body, cb)
+ )
+
+ queuesAddSubscribers: (queue_name, subscribers, cb) ->
+ parseResponseBind = _.bind(@parseResponse, @)
+
+ @post("/#{queue_name}/subscribers", subscribers, (error, response, body) ->
+ parseResponseBind(error, response, body, cb)
+ )
+
+ queuesRemoveSubscribers: (queue_name, subscribers, cb) ->
+ parseResponseBind = _.bind(@parseResponse, @)
+
+ @delete("/#{queue_name}/subscribers", subscribers, (error, response, body) ->
+ parseResponseBind(error, response, body, cb)
+ )
+
+ queuesDelete: (queue_name, cb) ->
+ parseResponseBind = _.bind(@parseResponse, @)
+
+ @delete("/#{queue_name}", {}, (error, response, body) ->
parseResponseBind(error, response, body, cb)
)
messagesPost: (queue_name, messages, cb) ->
parseResponseBind = _.bind(@parseResponse, @)
- @post("projects/#{@options.project_id}/queues/#{queue_name}/messages", {messages: messages}, (error, response, body) ->
+ @post("/#{queue_name}/messages", {messages: messages}, (error, response, body) ->
parseResponseBind(error, response, body, cb)
)
messagesGet: (queue_name, options, cb) ->
parseResponseBind = _.bind(@parseResponse, @)
- @get("projects/#{@options.project_id}/queues/#{queue_name}/messages", options, (error, response, body) ->
+ @get("/#{queue_name}/messages", options, (error, response, body) ->
parseResponseBind(error, response, body, cb)
)
messagesDelete: (queue_name, message_id, cb) ->
parseResponseBind = _.bind(@parseResponse, @)
-
- @delete("projects/#{@options.project_id}/queues/#{queue_name}/messages/#{message_id}", {}, (error, response, body) ->
+
+ @delete("/#{queue_name}/messages/#{message_id}", {}, (error, response, body) ->
+ parseResponseBind(error, response, body, cb)
+ )
+
+ messagesPeek: (queue_name, options, cb) ->
+ parseResponseBind = _.bind(@parseResponse, @)
+
+ @get("/#{queue_name}/messages/peek", options, (error, response, body) ->
+ parseResponseBind(error, response, body, cb)
+ )
+
+ messagesTouch: (queue_name, message_id, cb) ->
+ parseResponseBind = _.bind(@parseResponse, @)
+
+ @post("/#{queue_name}/messages/#{message_id}/touch", {}, (error, response, body) ->
+ parseResponseBind(error, response, body, cb)
+ )
+
+ messagesRelease: (queue_name, message_id, options, cb) ->
+ parseResponseBind = _.bind(@parseResponse, @)
+
+ @post("/#{queue_name}/messages/#{message_id}/release", options, (error, response, body) ->
+ parseResponseBind(error, response, body, cb)
+ )
+
+ messagesPushStatuses: (queue_name, message_id, cb) ->
+ parseResponseBind = _.bind(@parseResponse, @)
+
+ @get("/#{queue_name}/messages/#{message_id}/subscribers", {}, (error, response, body) ->
+ parseResponseBind(error, response, body, cb)
+ )
+
+ messagesPushStatusDelete: (queue_name, message_id, subscriber_id, cb) ->
+ parseResponseBind = _.bind(@parseResponse, @)
+
+ @delete("/#{queue_name}/messages/#{message_id}/subscribers/#{subscriber_id}", {}, (error, response, body) ->
parseResponseBind(error, response, body, cb)
)
View
78 src/client.coffee
@@ -33,6 +33,44 @@ class Client
cb(error, body)
)
+ update: (options, cb) ->
+ @api.queuesUpdate(@api.options.queue_name, options, (error, body) ->
+ if not error?
+ cb(error, body)
+ else
+ cb(error, body)
+ )
+
+ add_subscribers: (subscribers, cb) ->
+ unless subscribers instanceof Array
+ subscribers = [subscribers]
+
+ @api.queuesAddSubscribers(@api.options.queue_name, subscribers, (error, body) ->
+ if not error?
+ cb(error, body)
+ else
+ cb(error, body)
+ )
+
+ rm_subscribers: (subscribers, cb) ->
+ unless subscribers instanceof Array
+ subscribers = [subscribers]
+
+ @api.queuesRemoveSubscribers(@api.options.queue_name, subscribers, (error, body) ->
+ if not error?
+ cb(error, body)
+ else
+ cb(error, body)
+ )
+
+ del_queue: (cb) ->
+ @api.queuesDelete(@api.options.queue_name, (error, body) ->
+ if not error?
+ cb(error, body)
+ else
+ cb(error, body)
+ )
+
post: (messages, cb) ->
unless messages instanceof Array
messages = [messages]
@@ -56,6 +94,14 @@ class Client
cb(error, body)
)
+ peek: (options, cb) ->
+ @api.messagesPeek(@api.options.queue_name, options, (error, body) ->
+ if not error?
+ cb(error, if (not options.n?) or options.n == 1 then body.messages[0] else body.messages)
+ else
+ cb(error, body)
+ )
+
del: (message_id, cb) ->
@api.messagesDelete(@api.options.queue_name, message_id, (error, body) ->
if not error?
@@ -64,4 +110,36 @@ class Client
cb(error, body)
)
+ msg_touch: (message_id, cb) ->
+ @api.messagesTouch(@api.options.queue_name, message_id, (error, body) ->
+ if not error?
+ cb(error, body)
+ else
+ cb(error, body)
+ )
+
+ msg_release: (message_id, options, cb) ->
+ @api.messagesRelease(@api.options.queue_name, message_id, options, (error, body) ->
+ if not error?
+ cb(error, body)
+ else
+ cb(error, body)
+ )
+
+ msg_push_statuses: (message_id, cb) ->
+ @api.messagesPushStatuses(@api.options.queue_name, message_id, (error, body) ->
+ if not error?
+ cb(error, body)
+ else
+ cb(error, body)
+ )
+
+ del_msg_push_status: (message_id, subscriber_id, cb) ->
+ @api.messagesPushStatusDelete(@api.options.queue_name, message_id, subscriber_id, (error, body) ->
+ if not error?
+ cb(error, body)
+ else
+ cb(error, body)
+ )
+
module.exports.Client = Client
Something went wrong with that request. Please try again.