Skip to content

feat(client): make the WeakClient public and introduce Client::downgrade() to make it easier to get one - #7244

Open
bnjbvr wants to merge 3 commits into
matrix-org:mainfrom
nordeck:public-weak-client
Open

bnjbvr wants to merge 3 commits into
matrix-org:mainfrom
nordeck:public-weak-client

Conversation

@bnjbvr

@bnjbvr bnjbvr commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

The WeakClient (weak reference to a Client) is actually useful for external embedders too, who'd like to have access to Clients in long-running background tasks, but that shouldn't maintain the Client alive in this case.

First commit makes it public. Second commit mimick's Arc's API and introduces Client::downgrade(), which creates a WeakClient, and seems less weird / more idiomatic than the previous WeakClient::from_client method.

  • I've documented the public API changes in the appropriate changelog files (see [Writing changelog entries][pull-request-template-changelog]).
  • This PR was made with the help of AI.
    • all previous usages of WeakClient::from_client have been replaced with AI. I've reviewed those.

@bnjbvr
bnjbvr requested a review from a team as a code owner October 9, 2026 10:11
@bnjbvr
bnjbvr requested review from andybalaam and removed request for a team October 9, 2026 10:11
@codecov

codecov Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.41%. Comparing base (e3a21fd) to head (72599ce).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7244      +/-   ##
==========================================
- Coverage   90.43%   90.41%   -0.02%     
==========================================
  Files         416      416              
  Lines      122930   122930              
  Branches   122930   122930              
==========================================
- Hits       111174   111152      -22     
- Misses       7617     7626       +9     
- Partials     4139     4152      +13     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@codspeed

codspeed Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 50 untouched benchmarks


Comparing nordeck:public-weak-client (72599ce) with main (e3a21fd)

Open in CodSpeed

@bnjbvr
bnjbvr force-pushed the public-weak-client branch from 621129e to b21248e Compare October 9, 2026 13:40
bnjbvr added 3 commits October 9, 2026 15:44
…round tasks

Signed-off-by: Benjamin Bouvier <benjamin@bouvier.cc>
And use it throughout the code base instead of
`WeakClient::from_client`, which is more verbose and indirect.

Signed-off-by: Benjamin Bouvier <benjamin@bouvier.cc>
Signed-off-by: Benjamin Bouvier <benjamin@bouvier.cc>
@bnjbvr
bnjbvr force-pushed the public-weak-client branch from b21248e to 72599ce Compare October 9, 2026 13:44

This branch has not been deployed

No deployments
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.

1 participant