Splitting up the Worker and the Queue #116
Replies: 3 comments 3 replies
-
|
I will look at a PR if you open one. Since v6 hasn't been released yet there's still room for whatever breaking changes to made. |
Beta Was this translation helpful? Give feedback.
-
|
I've been thinking a bit about this and I'm not sure it adds much utility. Whichever way you look at it, both the worker and the queue need to have access to the task definitions (unless you don't need types, in which case you can already use enqueue_unsafe and/or type stubs to enqueue jobs without having task definitions). Unless I'm missing something? |
Beta Was this translation helpful? Give feedback.
-
|
Please see #125, I think this resolves all modularity concerns in a satisfactory way |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This is a great library. I love that it uses structured concurrency, I have read great things about it.
The one thing that has caused me some friction/confusion and I think it is apparent in other discussions as well is the worker context.
This appears in multiple places:
It's not very clear that the worker's async context manager doesn't actually start the worker. #94 (reply in thread)
It took me a bit to realize that it does not necessarily mean the worker has started and it's just necessary for enque.
There was also a discussion about modularity of the workers and a potential for task registry.
#44
I think all of these could be solved if the TaskQueue and the Worker were separated. The TaskQueue needs to know how to talk to the broker (Redis). It doesn't care about concurrency or orchestration.
The worker just takes the TaskQueue it wants to process as a parameter and it's generic over the TaskQueueContext, same as the TaskQueue it takes in. It mainly cares about the concurrency, orchestration etc. it doesn't care about the backend TaskQueue implementation
The TaskQueue's async context manager, all it allows you to do is enqueue tasks, you still have to start the worker itself from the CLI.
It's not very different from what you already have, it just more neatly separates concerns and makes for a clearer API imo.
It also might make it more easier to add additional backends.
Beta Was this translation helpful? Give feedback.
All reactions