Skip to content

Commit

Permalink
feat: support block only input for the timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
martonlederer committed Dec 3, 2024
1 parent 6a56560 commit 376dc30
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions process/handlers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -297,20 +297,34 @@ function handlers.advanced(config)
)

if config.timeout then
assert(type(config.timeout) == 'table', 'Invalid timeout: must be a table')
assert(
config.timeout.type == 'milliseconds' or config.timeout.type == 'blocks',
'Invalid timeout.type: must be of ("milliseconds" or "blocks")'
)
assert(
type(config.timeout.value) == 'number',
'Invalid timeout.value: must be an integer'
type(config.timeout) == 'table' or type(config.timeout) == 'number',
'Invalid timeout: must be a table or a number'
)

if type(config.timeout) == 'table' then
assert(
config.timeout.type == 'milliseconds' or config.timeout.type == 'blocks',
'Invalid timeout.type: must be of ("milliseconds" or "blocks")'
)
assert(
type(config.timeout.value) == 'number',
'Invalid timeout.value: must be an integer'
)
end
end

-- generate resolver for the handler
config.handle = handlers.generateResolver(config.handle)

-- handle timeout when it is a number (blocks)
if type(config.timeout) == 'number' then
config.timeout = {
type = 'blocks',
value = config.timeout
}
end

-- if the handler already exists, find it and update
local idx = findIndexByProp(handlers.list, 'name', config.name)

Expand Down

0 comments on commit 376dc30

Please sign in to comment.