-
Notifications
You must be signed in to change notification settings - Fork 84
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
Implementing capability caching #255
base: main
Are you sure you want to change the base?
Conversation
Codecov Report
Additional details and impacted files
|
|
||
// Capabilities are almost guaranteed to chance if encryption state or authentication state | ||
// changes, so caching them in `Connection` is inappropiate. | ||
capability_cache: Option<Capabilities>, |
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.
I don't know that I believe that we shouldn't have the cache be in Connection
. We can always just forcibly-reset it whenever the relevant underlying state changes (e.g., in login
). What do you think?
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.
I had two arguments for not caching the capabilities in the Connection
: Firstly and definitely the weaker of the two: Separation of concerns, namely doing so makes Connection
more than just a very thin shim over the underlying io::{Read + Write}
. Secondly and my main argument is that caching in Connection
has a smaller fuck-up-protection factor for the maintainers, i.e. "us, three years older". Clearing the cache becomes an active action that needs to be thought of, and forgetting to do so is still syntactically and semantically valid code, just one that may lead to bugs in code downstream. Having the cache in Session
/ Client
instead forces us to at least think about the cache when going from Client
to Session
or vice versa.
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.
While I think that's true, I also think the current split is a foot-gun because it means we have to replicate the cache state and logic in two places. If it was on Connection
, it would be in one place, which means one place to make improvements / bugfixes over time. I think I'd err on the side of simplicity here, as it'll be quite rare that we add a new way to wrap Connection
. And if we do, we're likely to do so by copy-pasting an existing wrapper first.
d120f0f
to
15d3f48
Compare
I think the last bit here now is #255 (comment) |
Based on this comment by @jonhoo on #243 this PR adds the ability for
Client
andSession
to cache returnedCapabilities
.Future work should try to parse (the optionally sent) Capabilities from untagged responses to
EHLO
,STARTTLS
, andAUTHENTICATE
automatically; if none are sent they should be automatically queried.This change is