Description
More and more information discovery is added in the Matrix-Spec. After the homeserver-versions and the exact domain, sliding sync is also adding the sliding-sync-proxy homeserver now. As of now the rust sdk need to make all these requests at every startup to resolve them or rely upon the higher level to hand it in (which is mostly hardcoded information at this point). Instead it would be great if we could define some caching mechanism for these that could automatically track when it was last refreshed and refresh them in certain intervals on long running processes or schedule a fetch when it notices they are stale at startup. Ideally these would also be persisted in the store for faster startup without remote requests.
I see two more functions added to the external interface to support for that. On ClientBuilder
we want to configure the discovery_cache_timeout(stale_timeout: Duration)
(but the default should just be 24h, I'd say) and on client itself we should have rediscover()
that force triggers the requests to refresh those discovery states.
Internally, I'd expect this to store the data itself and the datetime it was received persistently as well as in memory for faster access and refresh the state discovery through the outgoing_requests
-interface whenever that is necessary (so some scheduler would be necessary).
We probably want to have tests for that... probably with a mocked server with changing discovery data to ensure all parts of the app actually received that new information as soon as it is available.