[PR #776] [CLOSED] Adding a method to return a task's opts #1867

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

📋 Pull Request Information

Original PR: https://github.com/hibiken/asynq/pull/776
Author: @agorman
Created: 11/6/2023
Status: Closed

Base: masterHead: task-options


📝 Commits (1)

  • 4f1174d Adding a method to return a task's opts

📊 Changes

1 file changed (+1 additions, -0 deletions)

View changed files

📝 asynq.go (+1 -0)

📄 Description

I'd like to add an Options() method to Task that returns the []Option stored in t.opts.

My use case is that I'd like to be able to modify a task's payload inside a middleware. I haven't found a way that I can do that without losing the tasks options.

The way I'm currently doing it is as follows.

newTask  := asynq.NewTask(t.Type(), newPayload)
return h.ProcessTask(ctx, newTask)

I believe adding an Options() method to task is needed to preserve the options.

newTask := asynq.NewTask(t.Type(), newPayload, t.Options()...)
return h.ProcessTask(ctx, newTask)

If there is a better or already existing way to accomplish my use case I'd be happy to use that. Please let me know if adding the method and my use case is sane.

Thanks!


🔄 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/776 **Author:** [@agorman](https://github.com/agorman) **Created:** 11/6/2023 **Status:** ❌ Closed **Base:** `master` ← **Head:** `task-options` --- ### 📝 Commits (1) - [`4f1174d`](https://github.com/hibiken/asynq/commit/4f1174d3e2f74f1dead7520ca287e90f9fbf348e) Adding a method to return a task's opts ### 📊 Changes **1 file changed** (+1 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `asynq.go` (+1 -0) </details> ### 📄 Description I'd like to add an `Options()` method to `Task` that returns the `[]Option` stored in `t.opts`. My use case is that I'd like to be able to modify a task's payload inside a middleware. I haven't found a way that I can do that without losing the tasks options. The way I'm currently doing it is as follows. ~~~ newTask := asynq.NewTask(t.Type(), newPayload) return h.ProcessTask(ctx, newTask) ~~~ I believe adding an `Options()` method to task is needed to preserve the options. ~~~ newTask := asynq.NewTask(t.Type(), newPayload, t.Options()...) return h.ProcessTask(ctx, newTask) ~~~ If there is a better or already existing way to accomplish my use case I'd be happy to use that. Please let me know if adding the method and my use case is sane. Thanks! --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-07 22:13:37 +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#1867
No description provided.