Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

feature: Add cron-style periodic worker support #2351

Closed
Tracked by #2242
acaloiaro opened this issue Nov 13, 2022 · 5 comments
Closed
Tracked by #2242

feature: Add cron-style periodic worker support #2351

acaloiaro opened this issue Nov 13, 2022 · 5 comments
Assignees
Labels
breaking change This feature / fix introduces breaking changes enhancement New feature or request proposal A suggestion for a change, feature, enhancement, etc s: blocked is blocked by the other issues/PRs
Milestone

Comments

@acaloiaro
Copy link
Contributor

Description

Cron-style periodic workers are required by many applications. Less robust solutions can be concocted with PerformIn, which leaves room for a more explicit way to express job run periods.

Additional Information

I opened this Issue to reference #2308

@sio4 sio4 self-assigned this Nov 19, 2022
@sio4 sio4 added enhancement New feature or request breaking change This feature / fix introduces breaking changes proposal A suggestion for a change, feature, enhancement, etc labels Nov 19, 2022
@sio4
Copy link
Member

sio4 commented Nov 19, 2022

First, the PR #2308 is a breaking change invalidates all existing (official/unofficial/custom) implementations. It should be considered as a separate interface or extended when we redesign the Worker support in a future major version.

Second, the scope of the cron job is not clear.

The concept of the Workers is basically a kind of long-running task handler to help request handlers, by separating the time-consuming jobs which can be proceeded as a post process and do not directly affect the response. Good examples could be such as N-screen transcoding after video uploading or creating downloadable backup copy of the user data in background when a user requested a backup.

I think this periodic job (or periodic worker) is in the service scope (a kind of batch tasker for a whole service/application), which is not directly related to any HTTP request, and the implementation should be safe even though there are N instances of the same application in a single service if the code is in the application or we need a caution for it.

Providing a web based batch management interface, or Buffalo powered batch worker could be nice, but I am not fully sure if that feature could be a core of Buffalo and I feel we need more consideration if we going forward with it.

Still, this feature request is valuable and I think this is a great input for us as voice of the field. I am not going to merge the PR for now but if you provide ideas about batch job or your real situation, context, or use cases, I will be more than happy!

@sio4 sio4 added this to the v2.0.0 milestone Nov 21, 2022
@sio4 sio4 added the s: blocked is blocked by the other issues/PRs label Nov 21, 2022
@acaloiaro
Copy link
Contributor Author

acaloiaro commented Nov 27, 2022

Hi @sio4. As you may already know, I've not meaningfully contributed to buffalo in the past, so I'm not familiar with the typical procedure for proposing breaking changes. My usual proposal process for projects that don't have a contributing.md outlining the breaking-change process is to do what I've done with the PR #2308 and let project maintainers push back on PRs and propose how to move forward, if the PR is something they want to consider.

If we were to move forward with this concept, I think, like you suggest, that a new PeridoicWorker interface would be in order, and likely a new SimplePeriodic concrete implementation.


The concept of the Workers is basically a kind of long-running task handler to help request handlers, by separating the time-consuming jobs which can be proceeded as a post process and do not directly affect the response.

I think if this is the concept for a worker, then periodic workers are probably a poor fit for this project and I'd be happy to close the PR. However, if you're interested in expanding the concept of Workers to include use cases that are not so closely tied to "requests", then perhaps periodic works are a good fit for this project.

Personally I find periodic workers useful for operations such as

  • Running system tasks such as: batch emails, image processing, vacuuming databases, statistics/metrics reporting
  • Application-specific features: applications that fire webhooks on an interval; applications that "watch" remote resources for changes; etc.

If thee are use cases that you think Buffalo could serve, I'm happy to work on this further with you. Otherwise, feel free to close this issue and corresponding PR.

p.s. The CONTRIBUTING.md linked to in README.md is a broken link.

Cheers

@sio4
Copy link
Member

sio4 commented Nov 29, 2022

Oh, Thanks for letting me know about it! It seems like I missed updating README while I centralized CONTRIBUTING.md in the organization-wide .github repo. I will update it soon.

Yes, this kind of batch job is slightly different from the original worker concept, but as you said expanding the concept of worker could be nice and I believe there are users who want a batch job feature. So I would like to reconsider this expansion in the future once we redefine the worker concept in v2.

One of the important considerations of the worker would be reliability, which is not solid for now. If we consider a batch email of the announcement, for example, we should send a message to all users but just only one copy for a single user. So in a production environment with multiple application instances, we should have(or provide) a method to prevent duplicated running of a single job for the same target on multiple instances. There can be various methods for each use case so we can just document it, or we can consider implementing a solid systematic solution for it (could be limited to a specific range of use cases).

It could be nice if you could help us with this, including the design of the future worker, in future. Previously I filed a tracking issue for the new design of the worker for v2 as #2242, but I would like to use this issue as a tracking issue for the concept of batch/periodic worker. Please feel free to share your idea, feedback, or any thought here. It would be very helpful to us!

Many thanks!

@acaloiaro
Copy link
Contributor Author

acaloiaro commented Nov 29, 2022

Sounds good. I'll hop over to #2242 for any further design discussion.

@acaloiaro
Copy link
Contributor Author

I'm closing old issues. Since this has been open for a year without any activity, I'm closing it now.

If anyone wants to continue this issue further, feel free to reopen it.

Cheers

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
breaking change This feature / fix introduces breaking changes enhancement New feature or request proposal A suggestion for a change, feature, enhancement, etc s: blocked is blocked by the other issues/PRs
Projects
None yet
Development

No branches or pull requests

2 participants