-
Notifications
You must be signed in to change notification settings - Fork 269
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
feat(sdk): Welcome sliding_sync::Version
and sliding_sync::VersionBuilder
#3889
feat(sdk): Welcome sliding_sync::Version
and sliding_sync::VersionBuilder
#3889
Conversation
This patch replaces all the API using simplified sliding sync, or sliding sync proxy, by a unified `sliding_sync::Version` type! This patch disables auto-discovery for the moment. It will be re-enable with the next patches.
9440643
to
b917304
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3889 +/- ##
=======================================
Coverage 84.08% 84.08%
=======================================
Files 266 266
Lines 27744 27767 +23
=======================================
+ Hits 23328 23348 +20
- Misses 4416 4419 +3 ☔ View full report in Codecov by Sentry. |
This patch changes the type of `discover_homeserver_from_server_name_or_url`. It now returns a `Url` instead of a `String` for the homeserver URL. It also returns an `Option<get_supported_versions::Response>` in addition to the other values. The change from `String` to `Url` is necessary to avoid a double-parsing. It was parsed in `build()` but previously in `discover_homeserver_from_server_name_or_url` in the last branch. The addition of `get_supported_versions::Response` is necessary for the next patch. It's going to be helpful to auto-discover sliding sync in Synapse. The change happens here because `get_supported_versions::Response` is already received in `discover_homeserver_from_server_name_or_url`. This patch makes it easy to re-use it so that the request is sent only once. This patch therefore changes `check_is_homeserver` a little bit to become `get_supported_versions`, and inlines its previous call inside `discover_homeserver_from_server_name_or_url`.
a5f2815
to
e018677
Compare
sliding_sync::Version
and sliding_sync::VersionBuilder
This patch adds a builder for `sliding_sync::Version`. It is a similar enum except that it has `DiscoverProxy` and `DiscoverNative` to automatically configure `Version::Proxy` or `Version::Native`.
e018677
to
fa4ddde
Compare
Previous patches have unified all sliding sync versions behind a single type: `Version`. More recent previous patches have introduced `VersionBuilder` so that a `ClientBuilder` can use them to coerce or find the best `Version` possible. This patch implements a last missing piece: `Client::available_sliding_sync_versions` will report all available `Version`s at a given time. This is useful when a `Client` is already built, and a session has been opened/a user is logged, but someone has to take the decision whether it's useful to switch to another sliding sync version or not.
This patch adds bindings to `Client::available_sliding_sync_versions` to `matrix-sdk-ffi`. This patch also moves `Client::sliding_sync_version` from “private” to “public” FFI API, in thee sense that this method is now exported with UniFFI.
a413bff
to
54b066e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, thanks! Mostly minor comments, I'll help landing this.
Thanks for this clean refactoring!
For what it's worth, I've also disabled the complement-crypto required check on |
Ok(_) => { | ||
return Ok((homeserver_url, None, None)); | ||
Ok(response) => { | ||
return Ok((homeserver_url, None, Some(response))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦 of course! Thanks for the fix.
} | ||
} | ||
|
||
/// An error when building a version. | ||
#[derive(thiserror::Error, Debug)] | ||
pub enum VersionBuilderError { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎵 This is the story of a lazy man 🎵 with an awesome non-lazy co-worker 🎶
OK. So this PR should be reviewed commit-by-commit. It seems large, but most of the additions are tests.
This PR does 3 things. It's not possible to split them without breaking
main
.It removes
requires_sliding_sync
,sliding_sync_proxy
,is_simplified_sliding_sync_enabled
and all these messy configurations that are super error-prone (and that already contain at least one bug, e.g. it's possible to define a sliding sync proxy URL with simplified sliding sync enabled at the same time; now: which one is used? no error, but simplified sliding sync is taking precedence). Everything is replaced by a single, unique, simple:It feels much better after that:
None
.Proxy { url }
.Native
.After the introduction of
matrix_sdk::sliding_sync::Version
, the second part of the PR introducesmatrix_sdk::sliding_sync::VersionBuilder
that is used only bymatrix_sdk::ClientBuilder
. AVersionBuilder
is also an enum:It's designed to build a
Version
.VersionBuilder::None
maps toVersion::None
.Proxy
toProxy
.Native
toNative
. ThenDiscoverProxy
maps toProxy
by reading the.well-known
file; it expects"sliding_sync": { "url": … }
to contain a valid URL. AndDiscoverNative
maps toNative
by reading the/versions
API; it expects theunstable_features
to contain("org.matrix.simplified_msc3575", true)
(see Add a flag to /versions about SSS support element-hq/synapse#17571).A last small API is added:
Client::available_sliding_sync_versions()
to help an owner of aClient
to know whichVersion
s are available without the need to build aClient
withClientBuilder::sliding_sync_version(VersionBuilder::…).build()
and see whether it builds.Note: Complement Crypto breaks because the C FFI API has changed. This PR disables Complement Crypto. As soon as this PR is merged, I'll fix Complement Crypto, and re-enables it in this repository. Edit: PR is ready, matrix-org/complement-crypto#128.