-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option to keep the ttl while releasing the task #149
Conversation
…he release method of fifottl. Allows keep the task ttl unchanged when it necessary
queue/abstract/driver/fifottl.lua
Outdated
if opts.touch_ttl == nil then opts.touch_ttl = true end | ||
if opts.delay ~= nil and opts.delay > 0 then | ||
task = self.space:update(id, { | ||
local upd = { | ||
{ '=', i_status, state.DELAYED }, | ||
{ '=', i_next_event, util.event_time(opts.delay) }, | ||
{ '=', i_next_event, util.event_time(opts.delay) } | ||
} | ||
if opts.touch_ttl then | ||
table.insert(upd, | ||
{ '+', i_ttl, util.time(opts.delay) } | ||
}) | ||
) | ||
end | ||
task = self.space:update(id, upd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would name a new option in a way to make its default value false
: say, keep_ttl
. It looks more natural for me.
I guess the code hunk may be written in a simpler way (didn't tested):
task = self.space:update(id, {
{ '=', i_status, state.DELAYED },
{ '=', i_next_event, util.event_time(opts.delay) },
not opts.keep_ttl and { '+', i_ttl, util.time(opts.delay) } or nil,
})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fine advise. Renamed
queue/abstract/driver/fifottl.lua
Outdated
@@ -300,12 +300,18 @@ function method.release(self, id, opts) | |||
if task == nil then | |||
return | |||
end | |||
if opts.touch_ttl == nil then opts.touch_ttl = true end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to support it in 'utubettl' driver too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in new commit. Thanks for Your idea
queue/abstract/driver/fifottl.lua
Outdated
@@ -300,12 +300,18 @@ function method.release(self, id, opts) | |||
if task == nil then | |||
return | |||
end | |||
if opts.touch_ttl == nil then opts.touch_ttl = true end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We usually cover all new functionality with a test. Aren't you mind to add one? They're in the t/
directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Covered in new commit. Sorry for that
IMHO, introducing a new option that solely depends on another option is really not the best solution to the problem. I'm afraid it will be a source of confusion for users, because the API allows the "associated" option to be passed alone and, when allowed, is likely to be misused. So I expect to see in the future something like
which makes no sense (however, it gives a false impression that it somehow affects the task ttl). Moreover, when #125 gets implemented, we might get
which is a valid combination of options, although it looks very weird and confusing. As an alternative, I would consider adding a new standalone option, something like Another alternative is to introduce a new api method. |
After thinking more about the issue, I believe it can be solved in the scope of #125. If we had the ability to pass more options to
where |
Perhaps the option is not the best solution. But in the current implementation it doesn't seem confusive as the only case with ttl update is the release. |
HI! Thank you for the patch.
|
Perhaps the option is not the best solution. But in the current implementation it doesn't seem confusive as the only case with ttl update is the release.
My case is to retry failed tasks (http requests) every 30 seconds for 6-minutes period. So I need ttl to be constant. Shure if touch() could decrease ttl it would solve the issue along with "classic" release() |
Sorry it seems i close the request accidently. Let's me reopen |
Is it close to |
Well, thanks for the PR, but it looks like we haven't decided yet whether such functionality is needed in the module and how exactly the API of this functionality should look like. I think it would be good to resolve these questions in discussion #125, and then start implementing the feature. |
Adds the option 'touch_ttl' that is assotiated with delay option in the release method of fifottl. Allows keep the task ttl unchanged when it necessary. Might help with retries.