Permalink
Browse files

Publish messages via pubsub.

  • Loading branch information...
tim-smart committed Sep 22, 2011
1 parent 8fed5ce commit 780e4653361596350bd56100da4534543be93cd8
Showing with 14 additions and 9 deletions.
  1. +14 −9 index.js
View
@@ -63,22 +63,27 @@ exports.Queue = Queue;
Queue.prototype.write = function (payload, callback) {
var self = this;
var id = uuid();
var id = uuid()
, json = JSON.stringify
( { id : id
, payload : payload
, error_count : 0
, errors : []
, modified : Date.now()
}
)
// Push the job.
self.client.rpush(self.prefix + 'queue:' + self.name, JSON.stringify({
id: id,
payload: payload,
error_count: 0,
errors: [],
modified: Date.now()
}), function (error, length) {
self.client.multi()
self.client.rpush(self.prefix + 'queue:' + self.name, json);
self.client.publish(self.prefix + ':message', json)
self.client.exec(function (error) {
if (error) {
return handleError(error, callback);
}
if (callback) callback(null, id);
});
})
return id;
};

0 comments on commit 780e465

Please sign in to comment.