mirror of
https://github.com/hibiken/asynq.git
synced 2025-04-22 16:50:18 +08:00
39 lines
1.1 KiB
Go
39 lines
1.1 KiB
Go
package asynq
|
|
|
|
import (
|
|
"context"
|
|
|
|
asynqcontext "github.com/hibiken/asynq/internal/context"
|
|
)
|
|
|
|
// GetTaskID extracts a task ID from a context, if any.
|
|
//
|
|
// ID of a task is guaranteed to be unique.
|
|
// ID of a task doesn't change if the task is being retried.
|
|
func GetTaskID(ctx context.Context) (id string, ok bool) {
|
|
return asynqcontext.GetTaskID(ctx)
|
|
}
|
|
|
|
// GetRetryCount extracts retry count from a context, if any.
|
|
//
|
|
// Return value n indicates the number of times associated task has been
|
|
// retried so far.
|
|
func GetRetryCount(ctx context.Context) (n int, ok bool) {
|
|
return asynqcontext.GetRetryCount(ctx)
|
|
}
|
|
|
|
// GetMaxRetry extracts maximum retry from a context, if any.
|
|
//
|
|
// Return value n indicates the maximum number of times the assoicated task
|
|
// can be retried if ProcessTask returns a non-nil error.
|
|
func GetMaxRetry(ctx context.Context) (n int, ok bool) {
|
|
return asynqcontext.GetMaxRetry(ctx)
|
|
}
|
|
|
|
// GetQueueName extracts queue name from a context, if any.
|
|
//
|
|
// Return value qname indicates which queue the task was pulled from.
|
|
func GetQueueName(ctx context.Context) (qname string, ok bool) {
|
|
return asynqcontext.GetQueueName(ctx)
|
|
}
|