refactor(ads-client): restructure modules, strategy pattern for cache, clean MARS/client separation#7318
Merged
Almaju merged 2 commits intomozilla:mainfrom Apr 15, 2026
Conversation
d40ca48 to
9e872bd
Compare
43babb5 to
5bbdfb6
Compare
5bbdfb6 to
d8a175d
Compare
| /// `headers` are also excluded as they are request metadata, not cache keys. | ||
| impl Hash for AdRequest { | ||
| fn hash<H: Hasher>(&self, state: &mut H) { | ||
| self.url.as_str().hash(state); |
There was a problem hiding this comment.
I'm wondering if we should be storing the url query params for the hashing to be more robust?
Contributor
Author
There was a problem hiding this comment.
Ticket for follow-up: https://mozilla-hub.atlassian.net/browse/AC-101
| @@ -199,17 +229,25 @@ mod tests { | |||
| .expect(1) // only first request goes to network | |||
There was a problem hiding this comment.
_m.assert is required for .expect to work properly!
Contributor
Author
There was a problem hiding this comment.
Created ticket for follow-up https://mozilla-hub.atlassian.net/browse/AC-102
2a2b528 to
52919c7
Compare
…, clean MARS/client separation - HttpCache: remove generic, extract CacheFirst/NetworkFirst into strategy.rs, extract CacheOutcome into outcome.rs, rename cache_control.ttl to effective_ttl - MARSClient: owns API types (ad_request, ad_response, error, environment, report_reason), builds AdRequest internally, creates viaduct Client per-request - AdsClient: pure orchestrator — no URL construction, no environment field, delegates all HTTP concerns to MARSClient - Errors split: mars/error.rs (HTTP/API errors), client/error.rs (orchestration errors), ffi/error.rs (FFI bridge errors) - Merge add_request_hash_to_callbacks + add_placement_info_to_report_callbacks into single enrich_callbacks pass - All methods &mut self -> &self
HttpCacheError was a thin wrapper around rusqlite::Error — its Builder variant was never used since the builder already returns HttpCacheBuilderError directly. Remove it and propagate rusqlite::Error through clear_cache and invalidate_by_hash instead. Also splits CacheOutcome::StoreFailed (insert/upsert failures) from the new TrimFailed (size trim failures), and makes all error-bearing outcome variants consistent by using rusqlite::Error directly, matching LookupFailed.
52919c7 to
68bac7a
Compare
copyrighthero
approved these changes
Apr 15, 2026
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.
Pull Request checklist
[ci full]to the PR title.