Skip to content

Commit 21cd496

Browse files
committed
PR review
1 parent 227beb8 commit 21cd496

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

Sources/NIOPosix/Bootstrap.swift

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -531,9 +531,9 @@ extension ServerBootstrap {
531531

532532
enum Base {
533533
case hostAndPort(host: String, port: Int)
534-
case address(SocketAddress)
534+
case socketAddress(SocketAddress)
535535
case unixDomainSocketPath(String)
536-
case vsock(VsockAddress)
536+
case vsockAddress(VsockAddress)
537537
case socket(NIOBSDSocket.Handle)
538538
}
539539

@@ -560,8 +560,8 @@ extension ServerBootstrap {
560560
/// specifies the exact binding location, including IPv4, IPv6, or Unix domain addresses.
561561
///
562562
/// - Parameter address: The socket address to bind to
563-
public static func address(_ address: SocketAddress) -> BindTarget {
564-
BindTarget(base: .address(address))
563+
public static func socketAddress(_ address: SocketAddress) -> BindTarget {
564+
BindTarget(base: .socketAddress(address))
565565
}
566566

567567
/// Creates a binding target for a Unix domain socket.
@@ -587,8 +587,8 @@ extension ServerBootstrap {
587587
/// - Parameter vsockAddress: The VSOCK address to bind to, containing both
588588
/// context ID (CID) and port number
589589
/// - Note: VSOCK support depends on the underlying platform and virtualization technology
590-
public static func vsock(_ vsockAddress: VsockAddress) -> BindTarget {
591-
BindTarget(base: .vsock(vsockAddress))
590+
public static func vsockAddress(_ vsockAddress: VsockAddress) -> BindTarget {
591+
BindTarget(base: .vsockAddress(vsockAddress))
592592
}
593593

594594
/// Creates a binding target for an existing socket handle.
@@ -623,7 +623,7 @@ extension ServerBootstrap {
623623
/// let signalSource = DispatchSource.makeSignalSource(signal: SIGINT, queue: signalQueue)
624624
/// signalSource.setEventHandler {
625625
/// signalSource.cancel()
626-
/// print("\nreceived signal, initiating shutdown which should complete after the last request finished.")
626+
/// print("received signal, initiating shutdown which should complete after the last request finished.")
627627
///
628628
/// quiesce.initiateShutdown(promise: fullyShutdownPromise)
629629
/// }
@@ -666,17 +666,16 @@ extension ServerBootstrap {
666666
/// - onConnection: A closure to handle the connection. Use the channel's `inbound` property to read from
667667
/// the connection and channel's `outbound` to write to the connection.
668668
///
669-
/// - Note: If the server is not closed using a closure mechanism like above, the bind method must be cancelled using task
670-
/// cancellation for the method to return. Task cancellation will force close the server and wait for all remaining
671-
/// sub task (connection callbacks) to finish.
669+
/// - Note: The bind method respects task cancellation which will force close the server. If you want to gracefully
670+
/// shut-down use the quiescing helper approach as outlined above.
672671
@available(macOS 14.0, iOS 17.0, watchOS 10.0, tvOS 17.0, *)
673672
public func bind<Inbound: Sendable, Outbound: Sendable>(
674673
target: BindTarget,
675674
serverBackPressureStrategy: NIOAsyncSequenceProducerBackPressureStrategies.HighLowWatermark? = nil,
676675
childChannelInitializer: @escaping @Sendable (Channel) -> EventLoopFuture<NIOAsyncChannel<Inbound, Outbound>>,
677676
_ onConnection: @escaping @Sendable (
678677
_ channel: NIOAsyncChannel<Inbound, Outbound>
679-
) async throws -> ()
678+
) async -> ()
680679
) async throws {
681680
let channel = try await self.makeConnectedChannel(
682681
target: target,
@@ -695,10 +694,10 @@ extension ServerBootstrap {
695694
group.addTask {
696695
do {
697696
try await connectionChannel.executeThenClose { _, _ in
698-
try await onConnection(connectionChannel)
697+
await onConnection(connectionChannel)
699698
}
700699
} catch {
701-
// ignore single connection failures?
700+
// ignore single connection failures
702701
}
703702
}
704703
}
@@ -868,14 +867,14 @@ extension ServerBootstrap {
868867
childChannelInitializer: childChannelInitializer
869868
)
870869

871-
case .address(let address):
870+
case .socketAddress(let address):
872871
try await self.bind(
873872
to: address,
874873
serverBackPressureStrategy: serverBackPressureStrategy,
875874
childChannelInitializer: childChannelInitializer
876875
)
877876

878-
case .vsock(let vsockAddress):
877+
case .vsockAddress(let vsockAddress):
879878
try await self._bind(
880879
to: vsockAddress,
881880
serverBackPressureStrategy: serverBackPressureStrategy,

0 commit comments

Comments
 (0)