Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

appservice: Add client_with_config singleton #249

Merged
merged 7 commits into from
May 31, 2021

Conversation

johannescpk
Copy link
Contributor

@johannescpk johannescpk commented May 25, 2021

  • Adds new_with_client_config to allow configuring main appservice user client
  • Adds client_with_config to allow configuring virtual user clients
  • Exposes get_request_config on the Client
  • Refactors Appservice's client method to be a singleton that caches clients internally
  • Puts AppserviceRegistration into an Arc
  • Some cleanup
  • What's probably missing is a way to drop or re-initialize cached clients, added to the tracking issue
  • Reasoning for client method singleton: Since in an appservice context clients get often constructed on demand it could lead to easy footguns in terms of having multiple clients trying to sync, which is especially problematic in terms of E2EE

Part of #228

Copy link
Contributor

@poljar poljar left a comment

Choose a reason for hiding this comment

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

This doesn't seem to be finished up, and of course only now I see that it's a draft 😅.

matrix_sdk_appservice/src/lib.rs Outdated Show resolved Hide resolved
matrix_sdk_appservice/src/lib.rs Outdated Show resolved Hide resolved
@johannescpk johannescpk force-pushed the feat/appservice-client-config branch from 7f47cc7 to 8053480 Compare May 25, 2021 10:46
@johannescpk johannescpk force-pushed the feat/appservice-client-config branch 2 times, most recently from d04e944 to 4b6b1b0 Compare May 26, 2021 12:01
Comment on lines +183 to +185
/// Dummy type for shared documentation
#[allow(dead_code)]
pub type MainAppserviceUser = ();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wonder whether there's a more elegant way for rust docs glossaries 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, could probably work with simply a doc-only module and linking there

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I have been planing to do a matrix-sdk tutorial module for a while, though haven't managed to get around to it yet.

@johannescpk johannescpk marked this pull request as ready for review May 26, 2021 12:17
@johannescpk johannescpk requested a review from poljar May 26, 2021 12:17
@johannescpk johannescpk force-pushed the feat/appservice-client-config branch from 4b6b1b0 to 1372b6a Compare May 26, 2021 16:14
Copy link
Contributor

@poljar poljar left a comment

Choose a reason for hiding this comment

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

Looks good, but I don't think you need the &mut borrow, unless I'm missing something?

/// Since this method is a singleton follow-up calls with different
/// [`ClientConfig`]s will be ignored.
pub async fn client_with_config(
&mut self,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is that &mut still needed? I don't think you need it since the clients are in the dashmap.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, isn't needed anymore indeed

I wonder what it takes to teach clippy about DashMap 🤔

@johannescpk johannescpk force-pushed the feat/appservice-client-config branch from 1372b6a to 1df6d18 Compare May 31, 2021 10:50
@johannescpk johannescpk force-pushed the feat/appservice-client-config branch from 1df6d18 to 3f2fecd Compare May 31, 2021 10:50
@poljar poljar merged commit ee40d91 into matrix-org:master May 31, 2021
@poljar
Copy link
Contributor

poljar commented May 31, 2021

Thanks, merged.

@johannescpk johannescpk deleted the feat/appservice-client-config branch May 31, 2021 11:33
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