[GH-ISSUE #422] [FEATURE REQUEST] Possibility to configure retry strategy per task using Option API #2209

Closed
opened 2026-03-15 19:41:38 +03:00 by kerem · 3 comments
Owner

Originally created by @ajatprabha on GitHub (Mar 19, 2022).
Original GitHub issue: https://github.com/hibiken/asynq/issues/422

Originally assigned to: @hibiken on GitHub.

Is it currently possible to configure a task's retry mechanism from Option API? I see that we can specify MaxRetry, but can we also specify RetryBackoff strategy?

Describe the solution you'd like

asynq.RetryBackoff(asynq.RetryBackoffParams{
	InitialDelay:	time.Second,
	MaxDelay:	time.Minute,
	Type:		asynq.ExponentialBackoff, // Can be asynq.ConstantBackoff as well
})

Describe alternatives you've considered
I'm not sure how I can use RetryDelayFunc for this since it is passed on during initialisation and can't possibly have all the information with it beforehand.

Originally created by @ajatprabha on GitHub (Mar 19, 2022). Original GitHub issue: https://github.com/hibiken/asynq/issues/422 Originally assigned to: @hibiken on GitHub. Is it currently possible to configure a task's retry mechanism from Option API? I see that we can specify MaxRetry, but can we also specify RetryBackoff strategy? **Describe the solution you'd like** ```go asynq.RetryBackoff(asynq.RetryBackoffParams{ InitialDelay: time.Second, MaxDelay: time.Minute, Type: asynq.ExponentialBackoff, // Can be asynq.ConstantBackoff as well }) ``` **Describe alternatives you've considered** I'm not sure how I can use `RetryDelayFunc` for this since it is passed on during initialisation and can't possibly have all the information with it beforehand.
kerem 2026-03-15 19:41:38 +03:00
Author
Owner

@hibiken commented on GitHub (Mar 19, 2022):

@ajatprabha Thanks for opening an issue!

You could include that metadata in your payload and provide a custom RetryDelayFunc to use that metadata, and fallback to use DefaultRetryDelayFunc if that metadata is not present. Does that work for you?

<!-- gh-comment-id:1073015021 --> @hibiken commented on GitHub (Mar 19, 2022): @ajatprabha Thanks for opening an issue! You could include that metadata in your payload and provide a custom `RetryDelayFunc` to use that metadata, and fallback to use `DefaultRetryDelayFunc` if that metadata is not present. Does that work for you?
Author
Owner

@ajatprabha commented on GitHub (Mar 19, 2022):

Ok, I'll try this out and get back if I face any issues with it.

<!-- gh-comment-id:1073028030 --> @ajatprabha commented on GitHub (Mar 19, 2022): Ok, I'll try this out and get back if I face any issues with it.
Author
Owner

@hibiken commented on GitHub (Mar 22, 2022):

Closing this!

<!-- gh-comment-id:1074581142 --> @hibiken commented on GitHub (Mar 22, 2022): Closing this!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/asynq#2209
No description provided.