Skip to content
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

Enable ParSeq to run any task more than once #155

Open
itaimarts opened this issue Jan 21, 2018 · 3 comments
Open

Enable ParSeq to run any task more than once #155

itaimarts opened this issue Jan 21, 2018 · 3 comments

Comments

@itaimarts
Copy link

Hi,
As you wrote in your guide any task run only once. We have tasks that need to run multiple times (reuse of task), is that enabled at Parseq framework?

Usually the main goal of a task is to calculate a value. You can think of a task as an asynchronous function and once the value has been calculated there is no point in running the same task again. Thus, ParSeq will run any task only once. Engine will recognize task that has been completed (or even started) and will not run it again.

@jodzga
Copy link

jodzga commented Jan 21, 2018

It would be helpful to know more details about your use case but such situations we typically reuse a function that returns new task. You can see example use of this pattern in retry functionality:
https://github.com/linkedin/parseq/wiki/User%27s-Guide#retrying
Instead of reusing a Task and retrying it multiple times we use a function that returns new Task every time.

@itaimarts
Copy link
Author

Thanks for the quick response.
In high overview there are tasks which depends on machine state - the state can be changed between task executions and therefore task can success, failed or just return different results.

In our case, we want to add scheduled task, and would like to have the ability to get the task result at any given time.
If this ability will be supported by the framework it would improve the user experience with such cases.
what do you think?
thanks!

@jodzga
Copy link

jodzga commented Jan 22, 2018

Thanks for the suggestion.
I believe I understand what you mean. There is a tradeoff to consider here. Allowing to run tasks more than once would make your life slightly easier in this situation but the price for it would be increased complexity in other cases. The fact that task's result is immutable makes debugging and reasoning about the code much simpler.
I think it is pretty simple to achieve what you described by sharing (for read) an atomic reference to result instead the Task itself. Task would update that reference.
Does that make sense?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants