-
Notifications
You must be signed in to change notification settings - Fork 73
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
Lower EventLoopGroup requirements for creating bootstraps #49
Conversation
cc @weissi |
looks SemVer minor to me because this compiles:
but @glbrntt to verify using NIO's |
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.
looks good to me! I don't really like the PR because it makes it easier to pass a wrong event loop that won't work but what you intend to do is entirely reasonable so this must work. Also it brings it more in line with NIO core. Real fix is SemVer major and needs to be designed alongside apple/swift-nio#674
Motivation: In NIO `ClientBootstrap` and `ServerBootstrap` are initialized with an `EventLoopGroup`. Since `EventLoop` conforms to `EventLoopGroup` you can initialize an bootstrap with an existing event loop. In NIO Transport Services the bootstraps are initialized with a `NIOTSEventLoopGroup` and as `NIOTSEventLoop` conforms to `EventLoop` and by extension `EventLoopGroup` (but not `NIOTSEventLoopGroup`) it is not possible to initialize a bootstrap with a pre-existing `NIOTSEventLoop`. Modifications: Change the bootstrap initializers to accept an `EventLoopGroup`. Result: NIO Transport Services bootstraps can be initialized with a `NIOTSEventLoop`.
Not a fan either but I don't know of a better way to do this! I also added comments to the initialisers taking |
Thanks @glbrntt , having some explanation is great! |
Motivation:
In NIO
ClientBootstrap
andServerBootstrap
are initialized with anEventLoopGroup
. SinceEventLoop
conforms toEventLoopGroup
you caninitialize an bootstrap with an existing event loop. In NIO Transport
Services the bootstraps are initialized with a
NIOTSEventLoopGroup
andas
NIOTSEventLoop
conforms toEventLoop
and by extensionEventLoopGroup
(but notNIOTSEventLoopGroup
) it is not possible toinitialize a bootstrap with a pre-existing
NIOTSEventLoop
.Modifications:
Change the bootstrap initializers to accept an
EventLoopGroup
.Result:
NIO Transport Services bootstraps can be initialized with a
NIOTSEventLoop
.