This commit is contained in:
Axel Kittenberger 2018-06-24 22:24:55 +02:00
parent d0c6770b7c
commit 62517c2922
5 changed files with 57 additions and 36 deletions

View File

@ -32,6 +32,7 @@ proto.checkgauge =
init = true, init = true,
maxDelays = true, maxDelays = true,
maxProcesses = true, maxProcesses = true,
mindelay = true,
onAttrib = true, onAttrib = true,
onCreate = true, onCreate = true,
onModify = true, onModify = true,
@ -295,3 +296,8 @@ proto.prepare = function
check( config, gauge, '', level + 1 ) check( config, gauge, '', level + 1 )
end end
--
-- Default minimum 1 second delay to do anything
--
proto.mindelay = 1

View File

@ -32,7 +32,7 @@ local mt = { }
local k_nt = { } local k_nt = { }
local assignAble = local assignable =
{ {
dpos = true, dpos = true,
etype = true, etype = true,
@ -63,7 +63,7 @@ mt.__newindex = function
k, -- key value to assign to k, -- key value to assign to
v -- value to assign v -- value to assign
) )
if not assignAble[ k ] if not assignable[ k ]
then then
error( 'Cannot assign new key "' .. k .. '" to Delay' ) error( 'Cannot assign new key "' .. k .. '" to Delay' )
end end
@ -134,20 +134,20 @@ local function new
-- move destination -- move destination
) )
local delay = local delay =
{ {
blockedBy = blockedBy, blockedBy = blockedBy,
setActive = setActive, setActive = setActive,
wait = wait, wait = wait,
[ k_nt ] = [ k_nt ] =
{ {
etype = etype, etype = etype,
sync = sync, sync = sync,
alarm = alarm, alarm = alarm,
path = path, path = path,
path2 = path2, path2 = path2,
status = 'wait' status = 'wait'
}, },
} }
setmetatable( delay, mt ) setmetatable( delay, mt )

View File

@ -249,7 +249,7 @@ local eventFields =
event event
) )
return( return(
e2d[event].sync.source e2d[ event ].sync.source
.. ( .. (
string.match( getPath( event ), '^(.*/)[^/]+/?' ) string.match( getPath( event ), '^(.*/)[^/]+/?' )
or '' or ''
@ -362,6 +362,17 @@ local eventMeta =
-- --
local eventListFields = local eventListFields =
{ {
--
-- Returns a copy of the configuration as called by sync.
-- But including all inherited data and default values.
--
config = function
(
dlist
)
return dlist.sync.config
end,
-- --
-- Returns true if the sync this event list belongs to is stopped -- Returns true if the sync this event list belongs to is stopped
-- --
@ -380,7 +391,7 @@ local eventListFields =
local eventListFuncs = local eventListFuncs =
{ {
-- --
-- Returns a list of paths of all events in list. -- Returns a list of paths of all events in this list.
-- --
getPaths = function getPaths = function
( (
@ -431,9 +442,6 @@ local eventListMeta =
) )
if field == 'isList' then return true end if field == 'isList' then return true end
-- FIXME make an actual field
if field == 'config' then return e2d[ elist ].sync.config end
local f = eventListFields[ field ] local f = eventListFields[ field ]
if f then return f( e2d[ elist ] ) end if f then return f( e2d[ elist ] ) end

View File

@ -133,29 +133,23 @@ local function collect
error( 'collecting a non-active process' ) error( 'collecting a non-active process' )
end end
local rc = self.config.collect( local rc =
InletFactory.d2e( delay ), self.config.collect(
exitcode InletFactory.d2e( delay ),
) exitcode
)
if rc == 'die' if rc == 'die'
then then
log( 'Error', 'Critical exitcode.' ) log( 'Error', 'Critical exitcode.' )
terminate( -1 ) terminate( -1 )
elseif rc ~= 'again' elseif rc ~= 'again'
then then
-- if its active again the collecter restarted the event -- if its active again the collecter restarted the event
removeDelay( self, delay ) removeDelay( self, delay )
log( log(
'Delay', 'Delay', 'Finish of ', delay.etype, ' on ',
'Finish of ', self.source,delay.path, ' = ', exitcode
delay.etype,
' on ',
self.source,delay.path,
' = ',
exitcode
) )
else else
-- sets the delay on wait again -- sets the delay on wait again
@ -477,13 +471,13 @@ local function getAlarm
( (
self self
) )
-- first checks if more processes could be spawned
if self.stopped if self.stopped
or #self.processes >= self.config.maxProcesses or #self.processes >= self.config.maxProcesses
then then
return false return false
end end
-- first checks if more processes could be spawned
-- finds the nearest delay waiting to be spawned -- finds the nearest delay waiting to be spawned
for _, d in self.delays:qpairs( ) for _, d in self.delays:qpairs( )
do do
@ -862,6 +856,19 @@ local function new
error( 'delay must be a number and >= 0', 2 ) error( 'delay must be a number and >= 0', 2 )
end end
-- this is written in a negated way
-- since this way it will raise any issues of mindelay or delay
-- not being numbers as well
if not ( config.mindelay >= config.delay )
then
error(
'mindelay (= '..config.mindelay.. ') must be larger '..
'or equal than delay (= '..config.delay..')',
level
)
end
if config.filterFrom if config.filterFrom
then then
if not s.filters then s.filters = Filters.new( ) end if not s.filters then s.filters = Filters.new( ) end

View File

@ -358,7 +358,7 @@ end
-- --
SyncMaster = SyncMaster =
{ {
add = add, -- FIXME forward through metatable add = add,
remove = remove, remove = remove,
getRound = getRound, getRound = getRound,
concerns = concerns, concerns = concerns,