Make *arr retrieval process pluggable to support future enhancements #19

Closed
opened 2026-05-19 14:18:44 +01:00 by Gandalf · 1 comment
Owner

Problem Statement

While the Pluggable Download Client Architecture (PDCA) has successfully unified download-client handling (see #18), Sonarr and Radarr data retrieval remains hardcoded with direct Axios calls inside poller.js (and historyFetcher.js).

This tight coupling makes it difficult to introduce alternative retrieval strategies (such as event-driven listeners) without duplicating logic, risking regressions, or bloating the poller.

Goal

Introduce a clean, pluggable abstraction layer for all Sonarr and Radarr data retrieval that mirrors the PDCA pattern already used for download clients.

This refactor must:

  • Keep current polling behavior, caching, SSE broadcasting, error handling, timing logs, and public APIs 100% unchanged.
  • Significantly simplify poller.js.
  • Lay the architectural groundwork so a future webhook listener (or any other retrieval strategy) can push normalized data directly into the existing cache and SSE system without touching the poller.

Scope

  • Define an ArrRetriever abstract base class / interface (in server/clients/) with core methods:
    • getTags(instance)
    • getQueue(instance)
    • getHistory(instance, options?)
  • Create a central registry/factory (server/utils/arrRetrievers.js) modeled exactly after DownloadClientRegistry.
  • Implement default polling-based retrievers:
    • PollingSonarrRetriever
    • PollingRadarrRetriever
  • Move all existing Axios logic from poller.js (and affected parts of historyFetcher.js) into these new classes.
  • Update poller.js to use the registry generically (in the same style as download clients).
  • Ensure the design remains open for future implementations that feed the same normalized data and cache keys.
  • Comprehensive unit + integration tests for the new abstraction.
  • Minimal updates to documentation (e.g., ARCHITECTURE.md or README if present).

Normalized Data Requirements

All retrievers must return data in exactly the same shape and cache-key format currently used by the poller (no changes to existing cache keys, TTLs, or downstream consumers).

Success Metrics

  • 100% of existing functionality and performance characteristics are preserved (no regressions in dashboard updates, multi-instance support, or polling).
  • poller.js becomes noticeably smaller and focused only on orchestration.
  • The architecture is immediately ready for a follow-up webhook listener with zero further refactoring of the core retrieval layer.
  • All existing tests continue to pass.

Notes

  • This is a foundational, non-breaking refactor only.
  • The change must follow the exact style, error-isolation patterns, and naming conventions established in the PDCA (#18).
**Problem Statement** While the Pluggable Download Client Architecture (PDCA) has successfully unified download-client handling (see #18), Sonarr and Radarr data retrieval remains hardcoded with direct Axios calls inside `poller.js` (and `historyFetcher.js`). This tight coupling makes it difficult to introduce alternative retrieval strategies (such as event-driven listeners) without duplicating logic, risking regressions, or bloating the poller. **Goal** Introduce a clean, pluggable abstraction layer for all Sonarr and Radarr data retrieval that mirrors the PDCA pattern already used for download clients. This refactor must: - Keep **current polling behavior, caching, SSE broadcasting, error handling, timing logs, and public APIs 100% unchanged**. - Significantly simplify `poller.js`. - Lay the architectural groundwork so a future webhook listener (or any other retrieval strategy) can push normalized data directly into the existing cache and SSE system **without touching the poller**. **Scope** - Define an `ArrRetriever` abstract base class / interface (in `server/clients/`) with core methods: - `getTags(instance)` - `getQueue(instance)` - `getHistory(instance, options?)` - Create a central registry/factory (`server/utils/arrRetrievers.js`) modeled exactly after `DownloadClientRegistry`. - Implement default polling-based retrievers: - `PollingSonarrRetriever` - `PollingRadarrRetriever` - Move all existing Axios logic from `poller.js` (and affected parts of `historyFetcher.js`) into these new classes. - Update `poller.js` to use the registry generically (in the same style as download clients). - Ensure the design remains open for future implementations that feed the same normalized data and cache keys. - Comprehensive unit + integration tests for the new abstraction. - Minimal updates to documentation (e.g., ARCHITECTURE.md or README if present). **Normalized Data Requirements** All retrievers must return data in exactly the same shape and cache-key format currently used by the poller (no changes to existing cache keys, TTLs, or downstream consumers). **Success Metrics** - 100% of existing functionality and performance characteristics are preserved (no regressions in dashboard updates, multi-instance support, or polling). - `poller.js` becomes noticeably smaller and focused only on orchestration. - The architecture is immediately ready for a follow-up webhook listener with zero further refactoring of the core retrieval layer. - All existing tests continue to pass. **Notes** - This is a **foundational, non-breaking refactor** only. - The change must follow the exact style, error-isolation patterns, and naming conventions established in the PDCA (#18).
Gandalf added the Kind/Enhancement label 2026-05-19 14:23:01 +01:00
Author
Owner

This issue has been fully implemented. The pluggable *arr retrieval architecture (PALDRA) is now complete and in production.

Implementation Summary:

  • Created abstract base class defining the interface for all retrievers
  • Implemented and with polling-based data retrieval
  • Created singleton factory modeled after PDCA pattern
  • Updated to use the registry generically, significantly simplifying the code
  • Added comprehensive unit tests for the registry and retriever implementations
  • Updated ARCHITECTURE.md to document PALDRA (Pluggable *Arr Library Data Retrieval Architecture)

Key Commits:

  • 627329d - feat: implement Pluggable Abstraction Layer for Data Retrieval (PALDRA) - #19
  • 6e19992 - refactor: make PALDRA match PDCA style exactly
  • 5159a83 - fix(retrievers): Use unique key to prevent Sonarr/Radarr collision
  • ed4237d - feat(ombi): Add Ombi PALDRA integration for request management
  • 4aa3590 - test: comprehensive test coverage for PALDRA

The architecture is now ready for future retrieval strategies (e.g., webhook listeners) to push normalized data directly into the existing cache and SSE system without touching the poller logic, as originally specified.

This issue has been fully implemented. The pluggable *arr retrieval architecture (PALDRA) is now complete and in production. **Implementation Summary:** - Created abstract base class defining the interface for all retrievers - Implemented and with polling-based data retrieval - Created singleton factory modeled after PDCA pattern - Updated to use the registry generically, significantly simplifying the code - Added comprehensive unit tests for the registry and retriever implementations - Updated ARCHITECTURE.md to document PALDRA (Pluggable *Arr Library Data Retrieval Architecture) **Key Commits:** - 627329d - feat: implement Pluggable Abstraction Layer for Data Retrieval (PALDRA) - #19 - 6e19992 - refactor: make PALDRA match PDCA style exactly - 5159a83 - fix(retrievers): Use unique key to prevent Sonarr/Radarr collision - ed4237d - feat(ombi): Add Ombi PALDRA integration for request management - 4aa3590 - test: comprehensive test coverage for PALDRA The architecture is now ready for future retrieval strategies (e.g., webhook listeners) to push normalized data directly into the existing cache and SSE system without touching the poller logic, as originally specified.
Gandalf added the Area/Matching label 2026-05-28 11:58:41 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Gandalf/sofarr#19