Skip to content

Commit

Permalink
Renamed process_tick output
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Grondin committed Dec 16, 2018
1 parent 291ef96 commit 5821d9c
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 26 deletions.
16 changes: 8 additions & 8 deletions es5.js

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions lib/lua.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/redis/check.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local weight = tonumber(ARGV[3])

local capacity = process_tick(now, false)[1]
local capacity = process_tick(now, false)['capacity']
local nextRequest = tonumber(redis.call('hget', settings_key, 'nextRequest'))

return conditions_check(capacity, weight) and nextRequest - now <= 0
2 changes: 1 addition & 1 deletion src/redis/current_reservoir.lua
Original file line number Diff line number Diff line change
@@ -1 +1 @@
return process_tick(now, false)[3]
return process_tick(now, false)['reservoir']
2 changes: 1 addition & 1 deletion src/redis/free.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ local index = ARGV[3]

redis.call('zadd', job_expirations_key, 0, index)

return process_tick(now, false)[2]
return process_tick(now, false)['running']
2 changes: 1 addition & 1 deletion src/redis/increment_reservoir.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local incr = tonumber(ARGV[3])

redis.call('hincrby', settings_key, 'reservoir', incr)

local reservoir = process_tick(now, true)[3]
local reservoir = process_tick(now, true)['reservoir']

local groupTimeout = tonumber(redis.call('hget', settings_key, 'groupTimeout'))
refresh_expiration(0, 0, groupTimeout)
Expand Down
7 changes: 5 additions & 2 deletions src/redis/process_tick.lua
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,11 @@ local process_tick = function (now, always_publish)
else
redis.call('publish', 'b_'..id, 'capacity:'..(final_capacity or ''))
end

end

return {final_capacity, running, reservoir}
return {
['capacity'] = final_capacity,
['running'] = running,
['reservoir'] = reservoir
}
end
4 changes: 2 additions & 2 deletions src/redis/register.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ local weight = tonumber(ARGV[4])
local expiration = tonumber(ARGV[5])

local state = process_tick(now, false)
local capacity = state[1]
local reservoir = state[3]
local capacity = state['capacity']
local reservoir = state['reservoir']

local settings = redis.call('hmget', settings_key,
'nextRequest',
Expand Down
2 changes: 1 addition & 1 deletion src/redis/running.lua
Original file line number Diff line number Diff line change
@@ -1 +1 @@
return process_tick(now, false)[2]
return process_tick(now, false)['running']
2 changes: 1 addition & 1 deletion src/redis/submit.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local queueLength = tonumber(ARGV[3])
local weight = tonumber(ARGV[4])

local capacity = process_tick(now, false)[1]
local capacity = process_tick(now, false)['capacity']

local settings = redis.call('hmget', settings_key,
'id',
Expand Down

0 comments on commit 5821d9c

Please sign in to comment.