mirror of
https://github.com/hibiken/asynq.git
synced 2026-04-25 23:15:51 +03:00
[GH-ISSUE #218] [FEATURE REQUEST] return result to middleware #1091
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#1091
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 @ChristianYeah on GitHub (Dec 17, 2020).
Original GitHub issue: https://github.com/hibiken/asynq/issues/218
Originally assigned to: @hibiken on GitHub.
in some circumstances, a chained job task is required.
I prefer not to write the logic in the current task to re-queue the post-process task
however, the payload is not mutable and only errors will return by the task handler, the middleware is not able to catch any result directly(except the Redis, etc.)
I prefer to consider this as a discussion rather than a feature request, I'm not pretty professional in the system's structure design.
thank you
@hibiken commented on GitHub (Dec 17, 2020):
Hi @ChristianYeah! Thank you for starting this discussion.
I believe this is a common need, to create some kind of a workflow of sort.
Examples:
Do you have ideas on how the API should look like from the user of the library point of view?
@sujit-baniya commented on GitHub (Dec 21, 2020):
@hibiken There's a library for workflow: https://github.com/rdleal/go-async
Maybe the
Autopart is something you might consider.@sujit-baniya commented on GitHub (Dec 21, 2020):
Also in my view, for this library we need
@ChristianYeah commented on GitHub (Dec 21, 2020):
I think the simplest way is to allow the worker&task handler redirects its result to middleware or post-process middleware.
So developers could define the workflow in the payload rather than in golang code(rebuild & re-deploy are needed). users just need to ensure it's a non-cyclic graph or a DAG.
@hibiken commented on GitHub (Dec 22, 2020):
@ChristianYeah Do you think storing a result in the context would work? Using
WithValuefrom context package.I'm interested in building a feature for this in a longer term. I'll study how Celery and Sidekiq is handling this type of workflow.
@ChristianYeah commented on GitHub (Dec 23, 2020):
@hibiken I tried to override the context via
WithValuefunction in task'sProcessTaskfunction. however, I'm not able to get the value in the context in the middleware.@hibiken commented on GitHub (Dec 23, 2020):
Yes, you are right, it's not possible to store a result in context and make it available to middleware since context is immutable.
This may require API change in
Handlerinterface to return a result as well as an error. I'll work in the next iteration after I wrap up my current work on web ui.In the meantime, maybe you could store the result in redis and access it in middleware?
@hibiken commented on GitHub (Feb 15, 2021):
I'll move the discussion to #244 and close this one.