dhiaayachi / temporal

Temporal service
https://docs.temporal.io
MIT License
0 stars 0 forks source link

Improve retry with saved token #300

Open dhiaayachi opened 2 months ago

dhiaayachi commented 2 months ago

Is your feature request related to a problem? Please describe.

I need call in activity Azure Go SDK and here is part of logic. You get token for possible retry problems but I need own retry logic that I can't use retry with token in Temporal.

if token == nil {
    poller, err := clientFactory.NewApplicationsClient().BeginDelete(ctx, AzureDataResourceGroupName, appName, nil)
    if err != nil {
        return result, err
    }
    // save token (use for retry)
    token, _ := poller.ResumeToken()

    } else {
    poller, err = clientFactory.NewApplicationsClient().BeginDelete(ctx, AzureDataResourceGroupName, appName, &armmanagedapplications.ApplicationsClientBeginDeleteOptions{
        ResumeToken: token,
    })
}

Describe the solution you'd like

My idea, if we have possible save token for retry and can use if activity is retried that will be great.

Describe alternatives you've considered

No idea, I just write some my implementation that logic inside activity using my own db.

Additional context

Related discussion was in https://temporalio.slack.com/archives/CTDTU3J4T/p1692802525517009

dhiaayachi commented 1 month ago

Thank you for your feature request!

It's a great idea to have built-in support for storing and reusing resume tokens during activity retries. However, Temporal currently doesn't provide this functionality directly.

Here are some ways you could implement a workaround for now:

We understand that a built-in solution would be much simpler, and we encourage you to post your request on our community forum. We'll definitely consider adding this feature in future versions of Temporal.

dhiaayachi commented 1 month ago

Thank you for the feature request!

Temporal does not currently have the ability to automatically retry an Activity and reuse the ResumeToken from the previous execution, but you could potentially implement your retry logic within the Activity code using a custom database. This would allow you to store the token and access it on subsequent retries.

To avoid potential issues with concurrency, be sure to implement a locking mechanism within your custom database solution to ensure that multiple retries do not overwrite the ResumeToken.

Let us know if you have any other questions or feedback!

dhiaayachi commented 1 month ago

Thank you for reporting this feature request!

Temporal does not have built-in support for storing resume tokens, so you would need to implement your own logic to store and retrieve the token when retrying activities.

The documentation linked above describes Activities. This might help you develop a solution.