Allow binding multiple addresses#79
Conversation
| handler: some HTTPServerRequestHandler<RequestConcludingReader, ResponseConcludingWriter> | ||
| ) async throws { | ||
| let serverChannel = try await self.makeServerChannel() | ||
| let serverChannels = try await self.makeServerChannels() |
There was a problem hiding this comment.
We bind each channel to the listening addresses in this method. Does this method throw if the bind failed for a particular channel?
I'm wondering if we can reach a state where some channels are bound to an address and some are not; we should make sure that the channels which have already started are then closed in this case.
There was a problem hiding this comment.
Yeah good catch, we should close the channels. I'd assumed dropping the channels would trigger closes but I forgot we deprecated the closeOnDeinit by default on NIOAsyncChannel. I've fixed this.
| public var backpressureStrategy: BackPressureStrategy | ||
|
|
||
| /// Create a new configuration. | ||
| /// Create a new configuration with multiple bind targets. |
There was a problem hiding this comment.
We'll need to update the swift-configuration initializer (and the markdown reference table) too now that multiple bind targets are supported.
76df44e to
4b38661
Compare
7db71c8 to
1726688
Compare
This PR adds support for binding a
NIOHTTPServerto multiple addresses simultaneously.The configuration API now also accepts an array of
BindTargets. All resulting channels are served concurrently using the same request handler.The server treats its listening addresses as a unit: if any channel stops serving for any reason, all remaining channels are are also cancelled. This behaviour matches the current behaviour with a single listening address.
The
listeningAddressproperty has been replaced bylisteningAddresses, an array of addresses.