Refactor: decouple data plane from database via HTTP API#7
Merged
Conversation
- Migrates the worker's heartbeat mechanism from direct database updates (`queue.SetVisibleAfter`) to HTTP calls against the controller (`PUT /internal/executions/{id}/heartbeat`).
- Moves `VisibilityExtension` configuration from the worker to the controller, centralizing execution timeout policies.
- Decouples the Data Plane from the core storage layer, establishing the controller as the single source of truth for execution state transitions ahead of next features
- Implements `sendResult` in the worker agent to report execution success and failure via HTTP request. - Updates the controller's InternalUpdateResult handler to safely process execution results
- Introduces `POST /internal/executions/dequeue` in the controller - Implements `fetchWork` in the worker agent via HTTP, replacing direct `store.Queue.DequeueBatch` calls. - Removes `store.Queue` dependency entirely from the worker agent. - Achieves a 100% stateless Data Plane, enforcing the Control Plane as the sole authority for all execution lifecycles.
- Implements `doWithRetry` helper in the worker agent with exponential backoff and jitter to handle transient network failures. - Updates `sendResult` and `runHeartbeat` to use the retry mechanism, ensuring execution state updates reach the controller.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #7 +/- ##
==========================================
+ Coverage 67.36% 67.92% +0.56%
==========================================
Files 36 36
Lines 2108 2198 +90
==========================================
+ Hits 1420 1493 +73
- Misses 594 602 +8
- Partials 94 103 +9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
This PR completely decouples the
jobplaneworker (Data Plane) from PostgreSQL, making it 100% stateless and API-driven. Workers now communicate exclusively with the Controller via HTTP, establishing the Control Plane as the single source of truth for all execution state transitions.Why?
Previously, workers pulled jobs by executing
SELECT FOR UPDATE SKIP LOCKEDdirectly against the database. While fast, this hybrid approach introduced critical scaling limitations:PgBouncertransaction pooling.Important Changes
store.Queuedatabase interactions inagent.gowith HTTP calls using a new resilientdoWithRetryhelper.POST /internal/executions/dequeueto the controller. The controller now executes the safeSKIP LOCKEDquery on behalf of the worker.heartbeatsandresultsto survive transient network failures.PUT /internal/executions/{id}/resultfor reporting success and failure.