[PR #79] [MERGED] Make task handler context aware #1600

Closed
opened 2026-03-07 22:11:29 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hibiken/asynq/pull/79
Author: @hibiken
Created: 2/12/2020
Status: Merged
Merged: 2/12/2020
Merged by: @hibiken

Base: nextHead: feature/ctx


📝 Commits (4)

  • 52d2a6d Change Handler interface to take context.Context
  • 23bf33d Send cancellation signal to all in-progress handlers on shutdown
  • 174b940 Allow user to specify timeout per task
  • 5356fe9 Update docs for context and timeout

📊 Changes

10 files changed (+122 additions, -28 deletions)

View changed files

📝 README.md (+4 -1)
📝 background.go (+6 -5)
📝 background_test.go (+2 -1)
📝 benchmark_test.go (+4 -3)
📝 client.go (+19 -6)
📝 client_test.go (+27 -0)
📝 doc.go (+1 -1)
📝 internal/base/base.go (+6 -0)
📝 processor.go (+45 -4)
📝 processor_test.go (+8 -7)

📄 Description

Change Handler interface to take context as the first argument.

The context can be canceled in two scenarios (will be three in the future):

  • Background worker process is shutting down
  • User specified timeout duration has elapsed
  • User cancels a task manually via CLI (upcoming changes)

Handler implementation should check the context to support cancelation.

This closes part of #69


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hibiken/asynq/pull/79 **Author:** [@hibiken](https://github.com/hibiken) **Created:** 2/12/2020 **Status:** ✅ Merged **Merged:** 2/12/2020 **Merged by:** [@hibiken](https://github.com/hibiken) **Base:** `next` ← **Head:** `feature/ctx` --- ### 📝 Commits (4) - [`52d2a6d`](https://github.com/hibiken/asynq/commit/52d2a6ddc8864680a216b1de8122af5e6712a0ce) Change Handler interface to take context.Context - [`23bf33d`](https://github.com/hibiken/asynq/commit/23bf33d615840cd5b4528a24c00ef6a0bed5055f) Send cancellation signal to all in-progress handlers on shutdown - [`174b940`](https://github.com/hibiken/asynq/commit/174b9408c4811adb654ed517753b1bb1b7ae4c6f) Allow user to specify timeout per task - [`5356fe9`](https://github.com/hibiken/asynq/commit/5356fe9656a8372d4cfc53ee8b55ed27682bf532) Update docs for context and timeout ### 📊 Changes **10 files changed** (+122 additions, -28 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+4 -1) 📝 `background.go` (+6 -5) 📝 `background_test.go` (+2 -1) 📝 `benchmark_test.go` (+4 -3) 📝 `client.go` (+19 -6) 📝 `client_test.go` (+27 -0) 📝 `doc.go` (+1 -1) 📝 `internal/base/base.go` (+6 -0) 📝 `processor.go` (+45 -4) 📝 `processor_test.go` (+8 -7) </details> ### 📄 Description Change Handler interface to take context as the first argument. The context can be canceled in two scenarios (will be three in the future): - Background worker process is shutting down - User specified timeout duration has elapsed - User cancels a task manually via CLI (upcoming changes) Handler implementation should check the context to support cancelation. This closes part of #69 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-07 22:11:29 +03:00
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#1600
No description provided.