Add PerpetualJob type that self-enqueues from next_batch#204
Open
robacarp wants to merge 4 commits into
Open
Conversation
A PerpetualJob runs on a schedule (like PeriodicJob) but supports params (like QueuedJob) and knows how to enqueue itself. Subclasses implement `next_batch` which returns an Array of job instances, each configured with params for a single `perform` call. Every interval the framework calls `next_batch` and enqueues each returned instance. https://claude.ai/code/session_011P417H3rZzKjMoPqeTTcck
Instead of a separate PerpetualJob class hierarchy, add a next_batch hook to the Job base class. Any job can override next_batch to return an Array of QueuedJob instances; after a successful run the executor enqueues each one. This makes the perpetual pattern composable with any job type (QueuedJob, PeriodicJob, etc.). https://claude.ai/code/session_011P417H3rZzKjMoPqeTTcck
Introduces PerpetualJob (a QueuedJob subclass) with a `poll_every` macro that registers the job for periodic polling. A dedicated PerpetualJobRunner, driven by the Overseer alongside the Coordinator, periodically instantiates registered perpetual jobs and calls `next_batch` to discover and enqueue work — solving the initial enqueue problem without requiring external triggers. https://claude.ai/code/session_011P417H3rZzKjMoPqeTTcck
Instead of a dedicated PerpetualJob subclass, QueuedJob now detects at compile time (via macro finished) whether a subclass defines both next_batch and poll_every. When both are present, the job is auto-registered for periodic polling by the PerpetualJobRunner. This eliminates the separate type — any QueuedJob can opt in to polling by adding `poll_every` alongside its `next_batch` override. https://claude.ai/code/session_011P417H3rZzKjMoPqeTTcck
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A PerpetualJob runs on a schedule (like PeriodicJob) but supports
params (like QueuedJob) and knows how to enqueue itself. Subclasses
implement
next_batchwhich returns an Array of job instances, eachconfigured with params for a single
performcall. Every intervalthe framework calls
next_batchand enqueues each returned instance.https://claude.ai/code/session_011P417H3rZzKjMoPqeTTcck