AcceptBackoffHandler
A ChannelHandler
that implements a backoff for a ServerChannel
when accept produces an IOError
. These errors are often recoverable by reducing the rate at which we call accept.
final class AcceptBackoffHandler
A ChannelHandler
that implements a backoff for a ServerChannel
when accept produces an IOError
. These errors are often recoverable by reducing the rate at which we call accept.
final class AcceptBackoffHandler
import NIOCore
The core abstractions that make up SwiftNIO.
final class BackPressureHandler
ChannelHandler implementation which enforces back-pressure by stopping to read from the remote peer when it cannot write back fast enough. It will start reading again once pending data was written.
final class NIOCloseOnErrorHandler
A ChannelInboundHandler
that closes the channel when an error is caught
final class IdleStateHandler
Triggers an IdleStateEvent when a Channel has not performed read, write, or both operation for a while.
protocol ChannelHandler : AnyObject
Base protocol for handlers that handle I/O events or intercept an I/O operation.
protocol ChannelInboundHandler : _ChannelInboundHandler, _EmittingChannelHandler
ChannelHandler
which handles inbound I/O events for a Channel
.
protocol ChannelOutboundHandler : _ChannelOutboundHandler, _EmittingChannelHandler
ChannelHandler
which handles outbound I/O events or intercept an outbound I/O operation for a Channel
.
protocol RemovableChannelHandler : ChannelHandler
A RemovableChannelHandler
is a ChannelHandler
that can be dynamically removed from a ChannelPipeline
whilst the Channel
is operating normally. A RemovableChannelHandler
is required to remove itself from the ChannelPipeline
(using ChannelHandlerContext.leavePipeline
) as soon as possible.
protocol _ChannelInboundHandler : ChannelHandler
Untyped ChannelHandler
which handles inbound I/O events.
protocol _ChannelOutboundHandler : ChannelHandler
Untyped ChannelHandler
which handles outbound I/O events or intercept an outbound I/O operation.
protocol _EmittingChannelHandler
ChannelHandler which will emit data by calling ChannelHandlerContext.write
.
init(backoffProvider: @escaping (IOError) -> TimeAmount? = AcceptBackoffHandler.defaultBackoffProvider)
Create a new instance
init(shouldForwardIOErrorCaught: Bool, backoffProvider: @escaping (IOError) -> TimeAmount? = AcceptBackoffHandler.defaultBackoffProvider)
Create a new instance
static func defaultBackoffProvider(error: IOError) -> TimeAmount?
Default implementation used as backoffProvider
which delays accept by 1 second.
func channelInactive(context: ChannelHandlerContext)
func errorCaught(context: ChannelHandlerContext, error: Error)
func handlerRemoved(context: ChannelHandlerContext)
func read(context: ChannelHandlerContext)
typealias InboundIn = Channel
typealias OutboundIn = Channel
func bind(context: ChannelHandlerContext, to address: SocketAddress, promise: EventLoopPromise<Void>?)
func channelActive(context: ChannelHandlerContext)
func channelRead(context: ChannelHandlerContext, data: NIOAny)
func channelReadComplete(context: ChannelHandlerContext)
func channelRegistered(context: ChannelHandlerContext)
func channelUnregistered(context: ChannelHandlerContext)
func channelWritabilityChanged(context: ChannelHandlerContext)
func close(context: ChannelHandlerContext, mode: CloseMode, promise: EventLoopPromise<Void>?)
func connect(context: ChannelHandlerContext, to address: SocketAddress, promise: EventLoopPromise<Void>?)
func flush(context: ChannelHandlerContext)
func handlerAdded(context: ChannelHandlerContext)
Do nothing by default.
func register(context: ChannelHandlerContext, promise: EventLoopPromise<Void>?)
func removeHandler(context: ChannelHandlerContext, removalToken: ChannelHandlerContext.RemovalToken)
Implements the default behaviour which is to synchronously remove the handler from the pipeline. Thanks to this, stateless ChannelHandler
s can just use RemovableChannelHandler
as a marker-protocol and declare themselves as removable without writing any extra code.
func triggerUserOutboundEvent(context: ChannelHandlerContext, event: Any, promise: EventLoopPromise<Void>?)
func unwrapInboundIn(_ value: NIOAny) -> InboundIn
func unwrapOutboundIn(_ value: NIOAny) -> OutboundIn
func userInboundEventTriggered(context: ChannelHandlerContext, event: Any)
func wrapInboundOut(_ value: InboundOut) -> NIOAny
func wrapOutboundOut(_ value: OutboundOut) -> NIOAny
func write(context: ChannelHandlerContext, data: NIOAny, promise: EventLoopPromise<Void>?)