Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE REQUEST] Make handler context aware #69

Closed
hibiken opened this issue Jan 30, 2020 · 0 comments · Fixed by #81
Closed

[FEATURE REQUEST] Make handler context aware #69

hibiken opened this issue Jan 30, 2020 · 0 comments · Fixed by #81
Assignees
Labels
enhancement New feature or request idea Feature Suggestion or Idea

Comments

@hibiken
Copy link
Owner

hibiken commented Jan 30, 2020

We should support timeout per task and allow user to cancel task processing using the CLI.

Cancellation would be useful in two cases:

  • User manually cancels a in-progress task using the CLI
  • Background worker process is shutting down, so in-progress tasks should be cancelled

Optional timeout per task is used in cases such as:

  • For tasks that are best-effort. If processing could not complete within a certain timeout, bail and retry later.

In order to support both cancel and timeout, we need to change the Handler interface.

type Handler interface {
    func ProcessTask(ctx context.Context, t *Task) error
}

and add Timeout function to create a timeout option when scheduling a task.

client.Schedule(task, time.Now().Add(time.Hour), asynq.Timeout(10 * time.Second))

CLI will have a new command to cancel a in-progress task:

asynqmon cancel [task_id]

A cancelled task should be moved to retry state consuming a retry count.

@hibiken hibiken added the idea Feature Suggestion or Idea label Jan 30, 2020
@hibiken hibiken self-assigned this Jan 30, 2020
@hibiken hibiken added the enhancement New feature or request label Feb 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request idea Feature Suggestion or Idea
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant