Current step
implementation is not "scalable"
#57
Replies: 1 comment 3 replies
-
This is beyond the scope of Underway directly and therefore left out of the examples, but generally the approach that I take and would recommend is to implement generalized business logic independently of the job or task. For example, I have a "service" (sorry, this is an overloaded term, here I mean the design pattern and not e.g. a Tower service) that encapsulates sending emails. This service handles sending emails and can be called from anywhere the service is made available in my application--that could be in a job, different jobs, outside a job, etc. In its simplest form, I think having a set of functions that manage email sending is a good start, then each job that sends emails wraps such a function. This is a more general code reuse pattern but applies here as well. Regarding queue length, that actually should be straightforward: it's just |
Beta Was this translation helpful? Give feedback.
-
I've been considering the current
steps
approach, and it seems potentially limiting for scalability.What do I mean?
Take a standard example: generating a PDF and, once ready, sending an email with it. Suppose you already have a job specifically for sending emails. To send this PDF email, you’d need a unique
send email
step just for this scenario.Another example:
If you want to calculate a
job_queue_length
metric, thesteps
approach makes it a bit trickier. For example, the queue length ofsend-email
jobs is hidden within thesteps
structure, making it harder to track directly.This is why I think having dependencies between tasks might be a better fit.
For instance, a
task_dep
table could look something like this:When the system dequeues the next task, it would check to ensure that all dependencies are completed before proceeding.
WDYT?
UPDATE:
I actually like the syntax of the
steps
approach, so perhaps we could find a middle ground, where adding dependencies doesn't complicate things too much.Beta Was this translation helpful? Give feedback.
All reactions