-
Notifications
You must be signed in to change notification settings - Fork 95
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
Compatibility hazard with Key #291
Comments
I 100% agree, this is part of the reason tests were broken with Unfortunately, making this change would break backward compatibility :( |
Eeehhhh... I bolted on this feature and now I regret it. :D The problem is that dynamic keys are an opt-in and probably less used feature here, so we would be breaking the wrong side of users, I think. I can't figure out a sane way to reconcile things without breaking anyone. It seems to me that instead of wrapping a To ease the pain, I think what we could do is the release a version in which if the |
I mean we could always put it off till slog 3.0 🤷 Slog 3.0 doesn't have to be a huge rewrite or anything, it could just be:
Then we release a beta and call it Slog 3.0 😉 |
Big releases are a PITA for the ecosystem, because they require all the things to switch to new major version. There's a question - is it even worth it? Seems that If one was to build |
I was thinking about this for a while and the only somewhat reasonable approach I could figure out is:
Maybe there's a way to use semver trick to cleanup the names but I couldn't figure out how. |
Unfortunately, think something like this is what we're probably going to have to go with :( We would have to change pretty much every method in the Most users use slog macros instead of calling serializer methods directly, so slog consumers aren't hurt very much by this, mostly slog backends.
Yes. I think something like using feature flags is probably the "cleanest" way to go. Right now, we have the new type Key behind a Ideally, we would eventually invert this behavior. We would use a new type key by default, with the old behavior behind a feature flag. In slog 2.8 we could give nasty deprecation warnings for anyone using non-newtype keys. We could warn that newtype keys are becoming the new default and the old usage is deprecated. We could then suggest using Assuming they use the macros, clients are mostly unaffected by this change, it's implementers that will struggle with it. In slog 2.9 we could make
Yeah. I've been thinking about @dpc saying about ecosystem breakage in "slog 3.0" and he's unfortunately right. From the motivation from the semver-trick crate:
Ouch. Is it possible to use the semver trick with different versions traits and an adapter impls? So like we have something like This would allow slog2 clients to use slog3 serializer, at least in theory. We could also do it the other way around if we want, allowing slog3 clients to use slog2 serializers. Because of Rust's coherence rules, this could only work one way, not both. I guess the only way we could find out is by prototyping this type of semver compatibility hack and seeing what breaks ... In an ideal world, we'd want client updates from 2.8 -> 3.0 to be completely seamless with only a little breakage for logging backends..... I don't think there's any easy solution to this problem. |
I noticed that
Key
is a type alias or a newtype depending on used features. This is a compatibility hazard.For example:
Crate A:
Crate B:
With featrue
dynamic_keys
Crate C depends on both A and B -> crate A will break.
One can defend against this by always using
Key::from
, but it's possible to forget and clippy complains about useless conversion.I think the best course of action is to use a newtype for static keys too. It will be breaking for crates that don't defend but it's probably more predictable and easier to handle than the situation above.
The text was updated successfully, but these errors were encountered: