Skip to content

Commit

Permalink
v2.3.3 emit all slurry data with the onlineUntil event. Only emit the…
Browse files Browse the repository at this point in the history
… event if we're extending the lock
  • Loading branch information
redaphid / virgilvox committed Apr 12, 2017
1 parent e421ec5 commit f417d3d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "slurry-spreader",
"version": "2.3.2",
"version": "2.3.3",
"description": "Spread the Slurry around",
"main": "index.js",
"scripts": {
Expand Down
12 changes: 7 additions & 5 deletions src/spreader.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,12 @@ class SlurrySpreader extends EventEmitter2
return clearInterval @_extendLockInterval if @_isStopped()
locksToExtend = _.keys @slurries
debug "about to extend a bunch of locks. Probably, like, #{locksToExtend.length} or something."
_.each locksToExtend, @_emitOnlineUntil
async.each locksToExtend, @_extendOrReleaseLock, (error) =>
debug "extended #{locksToExtend.length} locks. Error: #{error?.stack}"

_emitOnlineUntil: (uuid) =>
_emitOnlineUntil: (slurry) =>
onlineUntil = moment().utc().add(@lockTimeout, 'ms')
@emit 'onlineUntil', {uuid, onlineUntil}
@emit 'onlineUntil', {slurry, onlineUntil}

remove: ({ uuid }, callback) =>
debug 'remove', uuid
Expand Down Expand Up @@ -177,8 +176,11 @@ class SlurrySpreader extends EventEmitter2
return callback() unless @_isSubscribed uuid # Might no longer be subscribed
return @_releaseLockAndRemoveFromQueue uuid, callback if _.isEmpty slurryData
return @_unsubscribe uuid, callback if @_isLockExpired uuid
return @_extendLock uuid, callback if slurryData.nonce == @slurries[uuid].nonce
return @_releaseLockAndUnsubscribe uuid, callback
return @_releaseLockAndUnsubscribe uuid, callback unless slurryData.nonce == @slurries[uuid].nonce

@_emitOnlineUntil slurryData
return @_extendLock uuid, callback


_getSlurry: (uuid, callback) =>
@redisClient.get "data:#{uuid}", (error, encrypted) =>
Expand Down

0 comments on commit f417d3d

Please sign in to comment.