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

Retry with different task #9

Open
kristiannotari opened this issue Jun 22, 2021 · 0 comments
Open

Retry with different task #9

kristiannotari opened this issue Jun 22, 2021 · 0 comments

Comments

@kristiannotari
Copy link

🚀 Feature request

Current Behavior

As of now, retrying a task means retrying the same task every time.

Desired Behavior

Depending on how/why the task failed there should be a way to retry with a different task. For example, if I need to update N items and M can fail to be updated, I would like to retry the update for only the M failed items.

Suggested Solution

The retry status could have the result of the previous task execution when the task is a Task<Either<A,B>> for example, in order to modify the task accordingly.

In the above described scenario, the task could succeed with a right or return a left with the unprocessed items. The task to be retried would be created using those unprocessed items, found in the retry status. There should also be a default (initial) value for the new property of the retry status, which could be the first task itself to be executed.

updateItems: (Item[]) => TaskEither<{ unprocessedItems: Item[], reason: string }, void>

itemsToBeUpdated: Item[]

retrying(
   // policy,
   ({ previousValue }) => updateItems(previousValue.unprocessedItems),
   E.isLeft,
  // initial value or initial task
  // Item[] 
  itemsToBeUpdated
  // or initial task
  updateItems(itemsToBeUpdated)
)

Who does this impact? Who is this for?

This would for all users.

Describe alternatives you've considered

May not be the best solution to pass the result in the retry status. The check action could act as a refinement too.

Additional context

Your environment

Software Version(s)
retry-ts 0.1.3
TypeScript 4.2.4
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

1 participant