Skip to content

refactor(ads-client): housekeeping - sort fields/methods, add UniFFI defaults, split docs, add Client in HttpCache#7316

Merged
Almaju merged 1 commit intomozilla:mainfrom
Almaju:ac-94-ads-client-refactoring
Apr 10, 2026
Merged

refactor(ads-client): housekeeping - sort fields/methods, add UniFFI defaults, split docs, add Client in HttpCache#7316
Almaju merged 1 commit intomozilla:mainfrom
Almaju:ac-94-ads-client-refactoring

Conversation

@Almaju
Copy link
Copy Markdown
Contributor

@Almaju Almaju commented Apr 9, 2026

  • Sort struct fields alphabetically (HttpCache)
  • Sort methods: constructors → pub (alpha) → private (alpha) in HttpCache, AdsClient, MARSClient
  • Add #[uniffi(default = None)] to optional FFI fields for better consumer ergonomics (iab_content, cache config fields, ttl_seconds)
  • Replace manual Default impl with #[derive(Default)] (clippy)
  • Split usage.md into per-language files (JavaScript, Kotlin, Swift) with only consumer-facing examples; update README links
  • Add viaduct::Client in HttpCache to make it compatible with future OHTTP impl

Pull Request checklist

  • Breaking changes: This PR follows our breaking change policy
    • This PR follows the breaking change policy:
      • This PR has no breaking API changes, or
      • There are corresponding PRs for our consumer applications that resolve the breaking changes and have been approved
  • Quality: This PR builds and tests run cleanly
    • Note:
      • For changes that need extra cross-platform testing, consider adding [ci full] to the PR title.
      • If this pull request includes a breaking change, consider cutting a new release after merging.
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Changelog: This PR includes a changelog entry in CHANGELOG.md or an explanation of why it does not need one
    • Any breaking changes to Swift or Kotlin binding APIs are noted explicitly
  • Dependencies: This PR follows our dependency management guidelines
    • Any new dependencies are accompanied by a summary of the due diligence applied in selecting them.

@Almaju Almaju changed the title refactor(ads-client): housekeeping — sort fields/methods, add UniFFI defaults, split docs refactor(ads-client): housekeeping - sort fields/methods, add UniFFI defaults, split docs Apr 9, 2026
@Almaju Almaju changed the title refactor(ads-client): housekeeping - sort fields/methods, add UniFFI defaults, split docs refactor(ads-client): housekeeping - sort fields/methods, add UniFFI defaults, split docs, add Client in HttpCache Apr 9, 2026
@Almaju Almaju force-pushed the ac-94-ads-client-refactoring branch 5 times, most recently from d49b8e6 to 31bdf94 Compare April 9, 2026 21:34
@Almaju Almaju marked this pull request as ready for review April 9, 2026 21:34
@Almaju Almaju force-pushed the ac-94-ads-client-refactoring branch 4 times, most recently from ddd764b to 94aadf8 Compare April 10, 2026 17:53
@copyrighthero
Copy link
Copy Markdown

Code review

Found 1 issue:

  1. Integration test compile error -- send_with_policy signature changed to require a new client: &Client first argument, but all three calls in the integration test file were not updated. The unit tests in src/http_cache.rs were correctly updated (they create a make_client() helper), but the integration test calls still pass only 2 arguments, causing E0061 ("this method takes 3 arguments but 2 arguments were supplied").

.expect(1)
.create();
// First call: miss -> store
let (_, outcomes) = cache
.send_with_policy(
req.clone(),
&CachePolicy::CacheFirst {
ttl: Some(Duration::from_secs(test_ttl)),
},
)
.unwrap();
assert!(matches!(outcomes.last().unwrap(), CacheOutcome::MissStored));

// Second call: hit (no extra HTTP due to expect(1))
let (response, outcomes) = cache
.send_with_policy(req.clone(), &CachePolicy::default())
.unwrap();
assert!(matches!(outcomes.last().unwrap(), CacheOutcome::Hit));

std::thread::sleep(Duration::from_secs(test_ttl));
let (response, outcomes) = cache
.send_with_policy(req, &CachePolicy::default())
.unwrap();
assert!(matches!(outcomes.last().unwrap(), CacheOutcome::MissStored));

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

…actor, split docs

- Sort struct fields and enum variants alphabetically throughout
- Sort methods: constructors → pub (alpha) → private (alpha)
- Add #[uniffi(default = None)] to optional FFI fields for better
  consumer ergonomics (iab_content, cache config fields, ttl_seconds)
- Replace manual Default impl with #[derive(Default)] (clippy)
- Merge CacheMode struct+enum into single CachePolicy enum with
  Duration ttl; rename send_with_options → send_with_policy
- Simplify fetch_and_cache TTL resolution: min(caller_ttl, server_ttl)
- Add Client to HttpCache with set_client() for transport abstraction
- Use Duration::from_secs() consistently instead of Duration::new(n, 0)
- Make each language doc (JS, Kotlin, Swift) a complete standalone guide
@Almaju Almaju force-pushed the ac-94-ads-client-refactoring branch from 94aadf8 to 058816e Compare April 10, 2026 18:44
@Almaju Almaju enabled auto-merge April 10, 2026 18:49
@Almaju
Copy link
Copy Markdown
Contributor Author

Almaju commented Apr 10, 2026

Thanks @copyrighthero
I pushed the fix for the integration test, CI should go green now.

@Almaju Almaju added this pull request to the merge queue Apr 10, 2026
Merged via the queue into mozilla:main with commit 0abbf92 Apr 10, 2026
15 checks passed
@Almaju Almaju deleted the ac-94-ads-client-refactoring branch April 10, 2026 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants