refactor(importer): decompose service into focused sub-packages#175
Merged
refactor(importer): decompose service into focused sub-packages#175
Conversation
Extract the 1700+ line importer service into a thin facade delegating to
specialized sub-services:
**New packages:**
- `queue/`: Worker pool management with exponential backoff retry
- Manager: Start/Stop/Pause/Resume worker lifecycle
- Claimer: Item claiming with database contention handling
- `scanner/`: Directory scanning and NZBDav imports
- DirectoryScanner: Manual directory scanning for NZB/STRM files
- NzbDavImporter: Bulk import from NZBDav databases
- `postprocessor/`: Post-import processing coordination
- Coordinator: Orchestrates symlinks, STRM files, VFS notifications,
health scheduling, and ARR notifications
**Changes to service.go:**
- Reduced from ~1700 to ~930 lines (~45% reduction)
- Service now delegates to queueManager, dirScanner, nzbdavImporter
- Implements queue.ItemProcessor interface for processing callbacks
- Type aliases maintain backward compatibility (ScanStatus, ImportInfo, etc.)
- Adapter types bridge Service to sub-service interfaces
**Benefits:**
- Single responsibility: each package has one clear purpose
- Testability: sub-services can be tested in isolation
- Maintainability: smaller, focused files are easier to understand
- Extensibility: new features can be added without touching core service
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <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
queue/package for worker pool management with exponential backoff retry (Manager, Claimer)scanner/package for directory scanning and NZBDav imports (DirectoryScanner, NzbDavImporter)postprocessor/package for post-import processing coordination (Coordinator orchestrating symlinks, STRM files, VFS notifications, health scheduling, ARR notifications)Test plan
go build ./...go test ./internal/importer/...🤖 Generated with Claude Code