mirror of
https://github.com/hibiken/asynq.git
synced 2026-04-25 23:15:51 +03:00
[GH-ISSUE #393] [FEATURE REQUEST] Add message headers #1187
Labels
No labels
CLI
bug
designing
documentation
duplicate
enhancement
good first issue
good first issue
help wanted
idea
invalid
investigate
needs-more-info
performance
pr-welcome
pull-request
question
wontfix
work in progress
work in progress
work-around-available
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/asynq#1187
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @AlexeyBelezeko on GitHub (Feb 1, 2022).
Original GitHub issue: https://github.com/hibiken/asynq/issues/393
Originally assigned to: @hibiken on GitHub.
I'm struggling a bit with passing trace id with the task. Cause there is no way to get it inside middleware without unmarshaling the payload. This adds unnecessary dependencies to middleware code.
I suggest adding
map[string]stringwith headers alongside with payload which lets users pass meta info alongside with payload.P.S.: Big thank you for your work. Sorry if i missed something in the docs and this actually possible.
@hibiken commented on GitHub (Feb 1, 2022):
@AlexeyBelezeko Thank you for opening a feature request!
Is it possible to use context values?
@AlexeyBelezeko commented on GitHub (Feb 2, 2022):
Unfortunately not. I inject trace_id and other meta info into context to use it inside Handlers but it didn't save me from exposing the inner structure of concrete handlers to middleware which I'm wanna avoid.
@hibiken commented on GitHub (Feb 3, 2022):
Hmm I see. Maybe similar to this feature request #326?
Could you give me a more concrete example of what you're trying to achieve? Code snippet would be very helpful here :)
@AlexeyBelezeko commented on GitHub (Feb 4, 2022):
In our project we run asynq server and client in two different processes. And to pass traceID i was forced to write middleware like this:
I suggest adding headers:
And this change will help to simplify middleware like this:
@crossworth commented on GitHub (Feb 4, 2022):
Would a partial unmarshal work here?
Since you dont need the others fields, just unmarshal on a struct with the fields that you need and are common to the tasks.
Or you could access the payload using another library for json handling like: https://github.com/tidwall/gjson
@AlexeyBelezeko commented on GitHub (Feb 4, 2022):
@crossworth thank you for your suggestion. But I also want to exclude this info from the payload to not affect uniqueness of the task.
For example, we have a few places in code which can add tasks to the same queue. Those tasks will have different trace ID and different payloads. To avoid duplications of work I have to use the TaskID. This will work perfectly with your solution. But I believe that meta info in headers more explicit and more simple solution.
@hibiken commented on GitHub (Feb 9, 2022):
Sorry for the delay in response here!
Let me think about this for a bit more since once a feature is added, it's hard to remove if we decide otherwise later.
@zhangzitao commented on GitHub (Oct 8, 2022):
@hibiken Any news? I long for this feature. Thanks for your work
@rapita commented on GitHub (May 10, 2023):
@hibiken Any news? If you accept this feature, I can continue to implement it in the PR https://github.com/hibiken/asynq/pull/606
@dennypenta commented on GitHub (May 10, 2023):
pls delegate the project owning to active contributors
@agorman commented on GitHub (Apr 26, 2024):
+1. I could really use this as well.
@dennypenta commented on GitHub (May 29, 2024):
share a link pls if anyone forked it