Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,24 @@ Sidekiq = (function() {
payload.jid = jid;
if (payload.at instanceof Date) {
payload.at = payload.at.getTime() / 1000;
return _this.redisConnection.zadd(_this.namespaceKey("schedule"), payload.at, JSON.stringify(payload), cb);
return _this.redisConnection.zadd(_this.namespaceKey("schedule"), payload.at, JSON.stringify(payload), function(err, response) {
if (err) {
return cb(err);
}
return cb(null, response, jid);
});
} else {
payload.enqueued_at = new Date().getTime() / 1000;
return _this.redisConnection.lpush(_this.getQueueKey(payload.queue), JSON.stringify(payload), function(err) {
if (err) {
return cb(err);
} else {
return _this.redisConnection.sadd(_this.namespaceKey("queues"), getQueueName(payload.queue), cb);
return _this.redisConnection.sadd(_this.namespaceKey("queues"), getQueueName(payload.queue), function(err, response) {
if (err) {
return cb(err);
}
return cb(null, response, jid);
});
}
});
}
Expand Down
8 changes: 6 additions & 2 deletions src/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ class Sidekiq
if payload.at instanceof Date
payload.at = payload.at.getTime() / 1000
# Push job payload to schedule
@redisConnection.zadd @namespaceKey("schedule"), payload.at, JSON.stringify(payload), cb
@redisConnection.zadd @namespaceKey("schedule"), payload.at, JSON.stringify(payload), (err, response) ->
return cb(err) if err
cb(null, response, jid)
else
# Add enqueued_at dat to payload
payload.enqueued_at = new Date().getTime() / 1000
Expand All @@ -38,6 +40,8 @@ class Sidekiq
cb(err)
else
# Create the queue if it doesn't already exist
@redisConnection.sadd @namespaceKey("queues"), getQueueName(payload.queue), cb
@redisConnection.sadd @namespaceKey("queues"), getQueueName(payload.queue), (err, response) ->
return cb(err) if err
cb(null, response, jid)

module.exports = Sidekiq