refactor: decompose executor.go into focused modules#3
Merged
simonovic86 merged 1 commit intomainfrom Mar 10, 2026
Merged
Conversation
Split the 1,380-line executor.go into 6 files by concern: - executor.go (260 lines): struct, constructor, Start/Stop, dashboard - executor_api.go (267): public API — Add, Get, Cancel, DLQ, Stats - executor_worker.go (243): workers, execute, middleware chain - executor_handlers.go (312): result/error/expiry handling - executor_schedule.go (109): scheduling, timers, replay - executor_maintenance.go (228): cleanup, stuck recovery, instance creation Also extracted submethods from handleResult() (162 → ~50 lines): - spawnChildren(): child instance creation and scheduling - spawnBarrier(): fan-in barrier creation - propagateIDs(): deduplicated trace/correlation ID propagation No behavioral changes. All methods remain on *Executor. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
Refactor the large monolithic
executor.gofile (1119 lines) into focused, single-responsibility modules:executor_api.go (267 lines): Public API methods for command management
Add,AddMany,Get,History,Cancel,CancelByTagReplayFromDLQ,FindDeadLettered,PurgeDLQ,Statsexecutor_handlers.go (312 lines): Command execution result and error handling
handleResult,handleError,handleExpiredspawnChildren,spawnBarrier,propagateIDsexecutor_maintenance.go (228 lines): Background maintenance tasks
cleanupLoop,stuckCommandRecoveryLoop,recoverStuckCommandscreateInstance,mergeSpecs, helper utilitiesexecutor_schedule.go (109 lines): Scheduling and timing logic
queueSchedule,scheduleDelayed,replay,cancelDelayedTimersstartPermanentCommandexecutor_worker.go (243 lines): Worker execution logic
worker,pollingWorker,claimAndExecute,executesafeExecute,executeWithMiddlewareBenefits
Migration
No breaking changes. All methods remain public with identical signatures.