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

feat: add auto_encoding and improve send_compressed behavior #2058

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Commits on Nov 19, 2024

  1. feat(fix): added auto_encoding and corrected default compression beha…

    …vior
    
    The service was initially configured to send compressed data only in Gzip format. Different clients requested varying compression algorithms (e.g., Gzip and Zstd).
    
    Logs showed the following behavior:
    1. Client 1 requested Gzip:
    ```
    Server received request: data="gzip", headers=MetadataMap { headers: {"te": "trailers", "content-type": "application/grpc", "grpc-encoding": "gzip", "grpc-accept-encoding": "gzip,identity", "user-agent": "tonic/0.13.0"} } Server sending response: gzip Responding with gzip compression
    ```
    2. Client 2 requested Zstd:
    ```
    Server received request: data="zstd", headers=MetadataMap { headers: {"te": "trailers", "content-type": "application/grpc", "grpc-encoding": "gzip", "grpc-accept-encoding": "zstd,identity", "user-agent": "tonic/0.13.0"} }
    ```
    
    It is clear that clients requested different encoders using `grpc-accept-encoding`.
    
    **Expected behavior:**
    - The server should select a compression algorithm from the intersection of the supported algorithms from the server and the client.
    - If the client requests a compression algorithm not supported by the server, the server should either use `identity` (no compression) or return a `UNIMPLEMENTED` status.
    
    **Actual behavior:**
    If any `send_compressed` configuration was set for the service, the `from_accept_encoding_header` method was triggered regardless of the `grpc-accept-encoding` header provided by the client.
    The function responsible for compression selection on the server did not respect `send_compression_encodings`.
    The server defaulted to the first supported compression algorithm from `grpc-accept-encoding` without checking if the algorithm was allowed by `send_compression_encodings`.
    
    **Resolution:**
    - If `send_compressed` is not specified, the server defaults to `identity`.
    - If `send_compressed` is specified, the server only compresses responses for clients explicitly requesting a supported algorithm.
    
    **Feature:**
    The `auto_encoding` mechanism was added. This allows the server to automatically
    select a compression algorithm supported by the client without requiring explicit configuration of `send_compressed` on the server.
    The server dynamically adjusts compression behavior, ensuring compatibility with client preferences for efficient communication.
    m62624 committed Nov 19, 2024
    Configuration menu
    Copy the full SHA
    b094032 View commit details
    Browse the repository at this point in the history
  2. test: add test

    m62624 committed Nov 19, 2024
    Configuration menu
    Copy the full SHA
    3872fcf View commit details
    Browse the repository at this point in the history
  3. refactor: remove warnings

    m62624 committed Nov 19, 2024
    Configuration menu
    Copy the full SHA
    df50a79 View commit details
    Browse the repository at this point in the history

Commits on Nov 20, 2024

  1. chore(docs): update comments

    m62624 committed Nov 20, 2024
    Configuration menu
    Copy the full SHA
    e1a86e1 View commit details
    Browse the repository at this point in the history

Commits on Nov 23, 2024

  1. Configuration menu
    Copy the full SHA
    7c4559f View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    0e681d4 View commit details
    Browse the repository at this point in the history

Commits on Nov 24, 2024

  1. Configuration menu
    Copy the full SHA
    b1d7088 View commit details
    Browse the repository at this point in the history