Skip to content

Comments

Bug 2018675 - Do not use a callback interface for MetricsHandler#7239

Queued
freshstrangemusic wants to merge 1 commit intomainfrom
freshstrangemusic/push-uxxopzmknnuu
Queued

Bug 2018675 - Do not use a callback interface for MetricsHandler#7239
freshstrangemusic wants to merge 1 commit intomainfrom
freshstrangemusic/push-uxxopzmknnuu

Conversation

@freshstrangemusic
Copy link
Member

Using a callback interface forces the type to come in as Box<T> instead of Arc<T> as a regular interface. We're storing it as an Arc<Box<T>> because we need it to be Send, so using a plain interface allows us to drop the Box and store a Arc<T> directly, preventing an additional layer of indirection.

Because the MetricsHandler is in an Arc, we can keep an Arc<TestMetrics> around and use it directly instead of dowcasting the reference inside Arc<dyn MetricsHandler> and so we can remove the NimbusClient::get_metrics_handler() test method.

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.

Using a callback interface forces the type to come in as `Box<T>`
instead of `Arc<T>` as a regular interface. We're storing it as an
`Arc<Box<T>>` because we need it to be `Send`, so using a plain
interface allows us to drop the `Box` and store a `Arc<T>` directly,
preventing an additional layer of indirection.

Because the MetricsHandler is in an Arc, we can keep an
`Arc<TestMetrics>` around and use it directly instead of dowcasting the
reference inside `Arc<dyn MetricsHandler>` and so we can remove the
`NimbusClient::get_metrics_handler()` test method.
@freshstrangemusic freshstrangemusic added this pull request to the merge queue Feb 23, 2026
Any commits made after this event will not be merged.
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