fractaledmind / acidic_job

Elegant, resilient, durable workflows for Rails apps
https://fractaledmind.github.io/acidic_job/
MIT License
486 stars 10 forks source link

Track number of executions in Run record #79

Open fractaledmind opened 1 year ago

fractaledmind commented 1 year ago

It is useful to know if a Run is in a retry or on the first run. For example, imagine a step method that makes an API call to create an external resource. That step method could fail during the "execution" stage such that the API call was successful, but the run errors while trying to close the transaction or update the Run record. In this case, the job will be retried and re-run this step method.

We can add another API call as a guard to check if the resource already exists in the external system, but on the first run of the job, this is guaranteed not to be the case (presuming the job is setup properly to be idempotent). We could save the API call on the first run and only check in subsequent runs, if we knew whether the run was a first run or not.