[GH-ISSUE #304] [FEATURE REQUEST] Adding a small amount of task information to asyncq.Task #126

Closed
opened 2026-03-02 05:18:53 +03:00 by kerem · 2 comments
Owner

Originally created by @zhaolion on GitHub (Aug 3, 2021).
Original GitHub issue: https://github.com/hibiken/asynq/issues/304

Originally assigned to: @hibiken on GitHub.

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

My feature: I need to know the number of retries to update the database related information. Currently the processor cannot get information about the number of retries related to the task

Describe the solution you'd like

func (processor *ImageProcessor) ProcessTask(ctx context.Context, t *asynq.Task) error {
	log.Printf("Retries: %d", t.Retries())
	return nil
}

** Additional context
This is a very marginal feature, and I rarely encounter it. If it is too difficult to do it, you can consider close this issue or consider to implement this feature in the next major version.

Originally created by @zhaolion on GitHub (Aug 3, 2021). Original GitHub issue: https://github.com/hibiken/asynq/issues/304 Originally assigned to: @hibiken on GitHub. **Is your feature request related to a problem? Please describe.** My feature: I need to know the number of retries to update the database related information. Currently the processor cannot get information about the number of retries related to the task **Describe the solution you'd like** ``` func (processor *ImageProcessor) ProcessTask(ctx context.Context, t *asynq.Task) error { log.Printf("Retries: %d", t.Retries()) return nil } ``` ** Additional context This is a very marginal feature, and I rarely encounter it. If it is too difficult to do it, you can consider close this issue or consider to implement this feature in the next major version.
kerem 2026-03-02 05:18:53 +03:00
Author
Owner

@crossworth commented on GitHub (Aug 3, 2021):

Hello @zhaolion.

You can use func GetRetryCount(ctx context.Context) (n int, ok bool) to get the retry count from the context.
https://pkg.go.dev/github.com/hibiken/asynq?utm_source=godoc#GetRetryCount

<!-- gh-comment-id:891446179 --> @crossworth commented on GitHub (Aug 3, 2021): Hello @zhaolion. You can use `func GetRetryCount(ctx context.Context) (n int, ok bool)` to get the retry count from the context. https://pkg.go.dev/github.com/hibiken/asynq?utm_source=godoc#GetRetryCount
Author
Owner

@zhaolion commented on GitHub (Aug 3, 2021):

Hello @zhaolion.

You can use func GetRetryCount(ctx context.Context) (n int, ok bool) to get the retry count from the context.
https://pkg.go.dev/github.com/hibiken/asynq?utm_source=godoc#GetRetryCount

cool, thanks for your comment

<!-- gh-comment-id:891545564 --> @zhaolion commented on GitHub (Aug 3, 2021): > Hello @zhaolion. > > You can use `func GetRetryCount(ctx context.Context) (n int, ok bool)` to get the retry count from the context. > https://pkg.go.dev/github.com/hibiken/asynq?utm_source=godoc#GetRetryCount cool, thanks for your comment
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#126
No description provided.