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

Backport: Add new protocol for ChannelHandler to get buffered bytes in the channel handler (#2918) #2982

Merged
merged 1 commit into from
Nov 21, 2024

Conversation

Lukasa
Copy link
Contributor

@Lukasa Lukasa commented Nov 21, 2024

This is a backport of #2918.

Add new protocol to get buffered bytes from ChannelHandlers and ChannelPipeline API to query the buffered bytes from ChannelHandlers

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 ChannelHandlers. This PR builds on #2849 by adding functionality to audit buffered bytes residing in ChannelHandlers 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 ChannelHandlers using the new ChannelPipeline APIs, enhancing the visibility of ChannelHandler performance.


Co-authored-by: Cory Benfield [email protected]
(cherry picked from commit 9356598)

…nel handler (apple#2918)

Add new protocol to get buffered bytes from `ChannelHandler`s and
`ChannelPipeline` API to query the buffered bytes from `ChannelHandler`s

### Motivation:

In apple#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 apple#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 <[email protected]>
(cherry picked from commit 9356598)
@Lukasa Lukasa added the 🆕 semver/minor Adds new public API. label Nov 21, 2024
@Lukasa Lukasa enabled auto-merge (squash) November 21, 2024 11:04
@Lukasa Lukasa merged commit d48b9dd into apple:sendable-backport-branch Nov 21, 2024
42 of 44 checks passed
@Lukasa Lukasa deleted the cb-backport-2918 branch November 21, 2024 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🆕 semver/minor Adds new public API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants