refactor: Merge Apify RQ storage clients into one class #643
+766
−1,085
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.
I didn't have an opportunity to provide feedback on #573 as it was merged while I was on vacation. While the implementation works well and the costs and performance improvements in
singlemode are great (good job @Pijukatel), I have concerns about the current architecture...IMO, we already have quite a lot of storage client classes: base classes with docstrings, the "storage client openers" for each backend type, and the individual storage clients for all storage types. By introducing the split into
singleandsharedmodes, we've added yet another layer to the Apify RQ storage client. Also, it implements the RQ storage client base class interface, but only partially. Altogether, this negatively affects readability, maintainability, and debuggability (I ran into this while investigating the truncated unique keys issue), and it increases code duplication (e.g., identical docstrings repeated in multiple places).This PR merges the three request queue client classes (
ApifyRequestQueueClient,ApifyRequestQueueSingleClient,ApifyRequestQueueSharedClient) into a singleApifyRequestQueueClientclass. Methods now use conditional logic based on the access parameter to determine whether to call_method_single()or_method_shared()variants.This change reduces the total lines of code, removes one layer of storage clients, eliminates docstring duplication, and all existing tests are passing.
Let me know what you think.