-
Notifications
You must be signed in to change notification settings - Fork 649
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
narrower bootstrap ELG requirements #674
Comments
While we can do this, I don’t know that it provides much utility. The issue is that any protocol we make here will be implementable by others, and so will not be a particularly good type constraint. I’m a bit more inclined to say that we should consider whether we can do something more sensible here: for example, given that in practice our Bootstraps are tightly tied to specific loop and channel implementations, perhaps they should be created by those loops and channels, rather than accepting them in the constructor. |
We should definitely think this through and make it more sensible. The quick fix (as Tanner describes) would be vastly better than what we have today because you don’t get weird error messages. As Thomas on the Vapor channel was pointing out, our docs for ClientBootstrap currently say it’s the best way to create tcp connections which is only partly true. So, if nothing else we should do the protocol but I’m sure we can come up with some proper solution which doesn’t allow for any ‘wrong type’ crashes there. Kind of like getting the bootstrap from the ELG, that might also allow us to have a more unified bootstrap protocol that works for NIO and NIOTS |
I think the best option here will be if the opaque result types proposal lands in Swift: in that case, we'll be able to use associated types on the |
Wanted to chime in (and hopefully help future searchers!) that I ran into this today trying to use
Totally possible there's a way to do this I'm not realizing, in which case I'm happy to update some docs/pointers somewhere! |
Currently there is not. |
We have got If that's not good enough, please file a new bug. |
So awesome, thanks for all the hard work, folks!! 🙇 |
NIO's bootstrap helpers like
ClientBootstrap
andServerBootstrap
currently accept any genericEventLoopGroup
. However, the event loops created by this group are eventually force casted to aSelectableEventLoop
. This effectively limits one to usingMultiThreadedEventLoop
orEmbeddedEventLoop
.I suggest narrowing the event loop groups accepted by these bootstraps to something like a
SelectableEventLoopGroup
protocol. That would help move some obvious programming errors, like passing aNIOTS*
event loop group to a standard NIO bootstrap, from runtime to compile time.The text was updated successfully, but these errors were encountered: