mirror of
https://github.com/apple/swift-nio
synced 2026-11-26 04:57:49 +00:00
Add new protocol to get buffered bytes from `ChannelHandler`s and `ChannelPipeline` API to query the buffered bytes from `ChannelHandler`s ### Motivation: In #2849, a new `ChannelOption` is introduced to retrieve the number of buffered outbound bytes in a `Channel`. However, this solution does not account for bytes that may be buffered within individual `ChannelHandler`s. This PR builds on #2849 by adding functionality to audit buffered bytes residing in `ChannelHandler`s and exposing this information through new `ChannelPipeline` APIs. ### Modifications: - Two new protocols for `ChannelHandler` to audit buffered bytes for inbound and outbound. - `NIOOutboundByteBufferingChannelHandler` - `NIOInboundByteBufferingChannelHandler` - New `ChannelPipeline` APIs - outboundBufferedBytes() - outboundBufferedBytes(in: ChannelHandlerContext) (only in `syncOperations`) - inboundBufferedBytes() - inboundBufferedBytes(in: ChannelHandlerContext) (only in `syncOperations`) ### Result: Users can now easily query the amount of bytes buffered in `ChannelHandler`s using the new `ChannelPipeline` APIs, enhancing the visibility of `ChannelHandler` performance. --------- Co-authored-by: Cory Benfield <lukasa@apple.com>