-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Many improvements to example scheduler
- Loading branch information
Showing
8 changed files
with
144 additions
and
24 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
daemons: | ||
web: | ||
image: web-v1.0.0 | ||
config: /configs/web.yaml | ||
celery: | ||
image: celery-v1.0.0 | ||
config: /configs/celery.yaml | ||
celery-beat: | ||
image: celery-v1.0.0 | ||
config: /configs/celery-beat.yaml |
3 changes: 3 additions & 0 deletions
3
example-configs/pyapp/runtime/pyapp/v3/required_processes.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
web: 10 | ||
celery: 20 | ||
celery-beat: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
inspect = require "inspect" | ||
|
||
function debugger() | ||
local x = {text=""} | ||
function x.object(self, title, data) | ||
self.text = self.text | ||
.. string.format('----- %s ----\n', title) | ||
.. inspect(data) | ||
.. "\n" | ||
end | ||
return x | ||
end | ||
|
||
function wrap_scheduler(real_scheduler) | ||
return function(state) | ||
local dbg = debugger() | ||
_G.print = function(...) dbg.print(...) end | ||
flag, value = pcall(_scheduler, state, dbg) | ||
_G.print = nil | ||
if flag then | ||
return value, dbg.text | ||
else | ||
text = dbg.text .. string.format("\nError: %s", value) | ||
return nil, text | ||
end | ||
end | ||
end | ||
|
||
return { | ||
debugger=debugger, | ||
wrap_scheduler=wrap_scheduler, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
function map(func, array) | ||
local new_array = {} | ||
for i,v in ipairs(array) do | ||
new_array[i] = func(v) | ||
end | ||
return new_array | ||
end | ||
|
||
function map_reverse(func, array) | ||
local new_array = {} | ||
for i=#array,1,-1 do | ||
new_array[#new_array+1] = func(array[i]) | ||
end | ||
return new_array | ||
end | ||
|
||
return { | ||
map=map, | ||
map_reverse=map_reverse, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
string = require "string" | ||
|
||
function compare(a, b) | ||
if a:sub(1, 1) == 'v' then a = a:sub(2) end | ||
if b:sub(1, 1) == 'v' then b = b:sub(2) end | ||
local aiter = string.gmatch(a, "%w+") | ||
local biter = string.gmatch(b, "%w+") | ||
while true do | ||
local aitem = aiter() | ||
local bitem = biter() | ||
if aitem == nil then return false end | ||
if bitem == nil then return true end | ||
if not (aitem == bitem) then | ||
if string.match("%d+", aitem) then | ||
if string.match("%d+", bitem) then | ||
local anum = tonumber(aitem) | ||
local bnum = tonumber(bitem) | ||
return anum < bnum | ||
else -- numbers are always less than letters | ||
return false | ||
end | ||
else | ||
if string.match("%d+", bitem) then | ||
-- numbers are always less than letters | ||
return true | ||
else | ||
return aitem < bitem | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
|
||
----- SELF TESTS ----- | ||
assert(compare("v1", "v2")) | ||
assert(not compare("v2", "v1")) | ||
assert(compare("v1.1", "v2.1")) | ||
assert(compare("v2.1", "v2.3")) | ||
assert(not compare("v2.3", "v2.1")) | ||
|
||
-- false for equal versions | ||
assert(not compare("v1", "v1")) | ||
assert(not compare("v2", "v2")) | ||
assert(not compare("v2.3.4", "v2.3.4")) | ||
|
||
local _sorttable = {"v1.1.0", "v1.0", "v3.4.6", "v1", "v2.3"} | ||
table.sort(_sorttable) | ||
assert(_sorttable[1] == "v1") | ||
assert(_sorttable[2] == "v1.0") | ||
assert(_sorttable[3] == "v1.1.0") | ||
assert(_sorttable[4] == "v2.3") | ||
assert(_sorttable[5] == "v3.4.6") | ||
_sorttable = nil |