Skip to content
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

Add an AcceptBackoffHandler to the async server bootstraps #2782

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Sources/NIOCore/ChannelHandlers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ public final class AcceptBackoffHandler: ChannelDuplexHandler, RemovableChannelH
scheduleRead(at: self.nextReadDeadlineNS!, context: context)
}
}
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm inclined to make this behaviour configurable. Users may be relying on the existing reporting, which makes sense as a default behaviour, but for the use-case we have it may well be sensible to suppress the error when it is "handled".

context.fireErrorCaught(error)
}
context.fireErrorCaught(error)
}

public func channelInactive(context: ChannelHandlerContext) {
Expand Down
4 changes: 4 additions & 0 deletions Sources/NIOPosix/Bootstrap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,10 @@ extension ServerBootstrap {
serverChannelInit(serverChannel)
}.flatMap { (_) -> EventLoopFuture<NIOAsyncChannel<ChannelInitializerResult, Never>> in
do {
try serverChannel.pipeline.syncOperations.addHandler(
AcceptBackoffHandler(),
name: "AcceptBackOffHandler"
)
try serverChannel.pipeline.syncOperations.addHandler(
AcceptHandler(childChannelInitializer: childChannelInit, childChannelOptions: childChannelOptions),
name: "AcceptHandler"
Expand Down