-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
usagepool: Adds generic UsagePoolOf
, deprecates UsagePool
#5731
Conversation
5d9ac36
to
7030d87
Compare
7030d87
to
d31392e
Compare
Ahhh, generics. Thanks for the PR. I suppose this makes sense. I'm not sure how much I love the (We're on feature freeze right now so this would have to wait until 2.9) |
Golang is strongly typed.. Ideally,
Feel free to commandeer this PR when you want to merge it |
I wanted to introduce a |
Just read about 2.7 feature freeze. Wouldn't consider this a feature as much as code cleanup / hardening |
I'm not against generics. I'm just careful to apply them at this stage, but getting more open to the idea as they get more mature. For example, I'd actually be happy to use Type parameters, well... they're more complicated and I'm not sure what the actual gain here is.
listenerPool also has to store net.Listener and net.UnixConn values.
I could possibly be convinced of this. However, this particular change is probably near the bottom of the priority list, and the implications of the change are still unknown to us, as generics are a very new feature of Go and this is a very crucial part of the code. So I'm wary is all. :) This is an exported API as well; quite different from internal-only code. The stakes are a bit higher, so I want to take time to get it right. I won't close this yet, but I just want time to consider it. Maybe have people try it out. I dunno. More discussion and experience. |
There isn't a common interface to the listeners beyond |
UsagePoolOf
, deprecates UsagePool
looks like #5749 will make quic use a |
I'm not inclined to merge this at this stage due to the reasons I stated above, and as I think on it more, I don't find the benefits compelling, which as I understand it, boil down to:
While I suppose type assertions (not casts) are technically "error-prone", it's extremely difficult to do this in practice at two levels because:
So I do appreciate the intent here to clean things up, but given the critical exported API, and the uncertainty of the implications and benefits at this stage, I'm going to close this for now. We can revisit this later though. :) Thank you so much for your time and effort! |
Adds much-needed type safety for UsagePool with a new type, UsagePoolOf.
UsagePool definition and public interfaces intact, with deprecation warning.
Updates usages within core modules, and adds specific value types to UsagePools, except for listenerPool, for which there is no interface common to quic.EarlyListener and the net package.