Skip to content

chore(hub): Deprecate Hub::with#1126

Open
szokeasaurusrex wants to merge 1 commit into
szokeasaurusrex/thread-hub-simplificationfrom
szokeasaurusrex/deprecate-hub-with
Open

chore(hub): Deprecate Hub::with#1126
szokeasaurusrex wants to merge 1 commit into
szokeasaurusrex/thread-hub-simplificationfrom
szokeasaurusrex/deprecate-hub-with

Conversation

@szokeasaurusrex
Copy link
Copy Markdown
Member

@szokeasaurusrex szokeasaurusrex commented May 8, 2026

Following the safety improvements in #1123, Hub::with no longer offers any performance benefit over using Hub::current. Hub::current provides a simpler API, and also returns an owned Arc<Hub> rather than providing access to a &Arc<Hub> via a callback (necessitating a second clone for anyone needing an owned Arc<Hub> in that callback).

As Hub::current is the arguably better API, let's deprecate Hub::with and encourage folks to migrate.

Stacked on #1125

Following the safety improvements in #1123, `Hub::with` no longer offers any performance benefit over using `Hub::current`. `Hub::current` provides a simpler API, and also returns an owned `Arc<Hub>` rather than providing access to a `&Arc<Hub>` via a callback (necessitating a second clone for anyone needing an owned `Arc<Hub>` in that callback).

As `Hub::current` is the arguably better API, let's deprecate `Hub::with` and encourage folks to migrate.
Comment thread sentry-core/src/hub.rs
@szokeasaurusrex szokeasaurusrex marked this pull request as ready for review May 8, 2026 12:20
@szokeasaurusrex szokeasaurusrex requested a review from lcian as a code owner May 8, 2026 12:20
Copy link
Copy Markdown
Member

@lcian lcian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, to the user we always give out an Arc::clone, and internally we use the direct with_borrow path which may panic, which we're making sure to use safely.
LGTM

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