mirror of
https://github.com/hibiken/asynq.git
synced 2026-04-25 23:15:51 +03:00
[GH-ISSUE #179] [FEATURE REQUEST] Trackable UID for publishing events #1071
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#1071
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 @xkortex on GitHub (Jul 3, 2020).
Original GitHub issue: https://github.com/hibiken/asynq/issues/179
Originally assigned to: @hibiken on GitHub.
Is your feature request related to a problem? Please describe.
Currently, tasks are "fire and forget". There is no way to check on a particular task once it's been enqueued. I can think of several instances where you may want to perform different logic if a task fails / times out (without getting into a full-blown scheduler of course!)
Example use case: for exeq jobs, I'd like to notify the client UI if something causes the job to bounce too many times. Usually this means something is misconfigured.
Describe the solution you'd like
There are a few possible ways to solve this.
Add an
Optionwhich lets the caller ofEnqueuespecify the ID to use, overriding xid.New().Add new argument to Enqueue to specify the ID to use, overrIding xid.
Put a ID field in
struct Task. Empty string passed to Enqueue results inxid.New().Return the value generated by client submission. This would change the signature to
Enqueue(t *Task, opts ...Option) (id string, err error).some combo of 2 and 4, with a new
EnqueueID(t * Task, id string, opts ...) (id string, err error)Pros/cons:
Pros: gives you more granular control over ID generation. Cons: Doesn't really fit with the idea of "options". Lets user potentially shoot themselves in the foot
Pros: granular. Cons: more clutter if you just want random ID. Footgun.
Pros: clean, seems logical that the same conceptual Task should have the same ID. Cons: Footgun.
Pros: Feels most idiomatic. Probably a good idea even in case of 1/2. Cons: bigger API change than adding a field to a struct. Will result in lots of
_, err := Enqueue()if people don't care and just want random.meh, probably the most lackluster option. Extra code.
All 5 would require SOME api change, so that is a con for all, though that is the nice part about being in v0.*. But that might be the right move in the long run anyways. The common theme with anything allowing the user to set the ID is flexibility in exchange for possibility of setting off duplicate IDs and shooting themselves in the foot.
Describe alternatives you've considered
some gross reflection hacks to figure out the most recent job submitted 🤷
@hibiken commented on GitHub (Jul 3, 2020):
@xkortex Thanks for opening this issue!
#178 will resolve this issue. It's similar to 4 approach you suggested above.
Let me know if you have thoughts on the new API.
Thanks!