Skip to content

Conversation

tsubakiky
Copy link
Collaborator

@tsubakiky tsubakiky commented Apr 24, 2025

conformance result:

$ connectconformance --conf ./server_config.yaml --mode server -- uv run python server_runner.py
Total cases: 2072
2072 passed, 0 failed

conformance server config:

features:
  versions:
    - HTTP_VERSION_1
    - HTTP_VERSION_2
  protocols:
    - PROTOCOL_CONNECT
    - PROTOCOL_GRPC
  codecs:
    - CODEC_PROTO
    - CODEC_JSON
  compressions:
    - COMPRESSION_IDENTITY
    - COMPRESSION_GZIP
  stream_types:
    - STREAM_TYPE_UNARY
    - STREAM_TYPE_CLIENT_STREAM
    - STREAM_TYPE_SERVER_STREAM
    - STREAM_TYPE_HALF_DUPLEX_BIDI_STREAM

  supports_trailers: true
  supports_tls: true
  supports_tls_client_certs: true
  supports_half_duplex_bidi_over_http1: true
  supports_h2c: true
  supports_connect_get: true
  supports_message_receive_limit: false

@tsubakiky tsubakiky changed the title unary grpc server support grpc server Apr 24, 2025
@tsubakiky tsubakiky changed the title support grpc server handler: support grpc protocol May 1, 2025
@tsubakiky tsubakiky force-pushed the unary-grpc-server branch from 1149d68 to 2be0c01 Compare May 1, 2025 10:50
@tsubakiky tsubakiky requested a review from Copilot May 1, 2025 10:52
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for the gRPC protocol along with updated streaming response handling (including trailers), refactors various protocol and handler components, and adjusts related configuration and client examples to accommodate the new features.

  • Added gRPC (and grpc-web) support and enabled trailers in the streaming response implementation.
  • Refactored handler and protocol modules to use instance methods instead of external implementation functions.
  • Updated dependency configurations and example clients to reflect these protocol changes.

Reviewed Changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/connect/streaming_response.py Introduces a streaming response class with trailer support.
src/connect/protocol.py Adds GRPC protocol constants and adjusts protocol header exclusions.
src/connect/handler.py Refactors handler implementation to use instance methods and removes typeguard checks.
src/connect/error.py Adds a helper to return error details as Any messages.
src/connect/envelope.py Introduces EnvelopeWriter/Reader classes and related envelope functions.
src/connect/connect.py Refactors message receiving functions and stream validation methods.
pyproject.toml Adds googleapis-common-protos dependency.
examples/pyproject.toml Adjusts example dependencies.
examples/cmd/examples-go/client/main.go Updates Go client to use an HTTP/2 transport with gRPC configuration.
conformance/server_config.yaml Enables GRPC protocol and trailer support.
conformance/run-testcase.txt Updates test cases for gRPC support.
conformance/pyproject.toml Updates dependency sources for conformance tests.
Comments suppressed due to low confidence (1)

src/connect/envelope.py:228

  • The error message contains a typo: 'send_mas_bytes' should be 'send_max_bytes' to accurately reflect the variable name.
raise ConnectError(f"compressed message size {len(data)} exceeds send_mas_bytes {self.send_max_bytes}",

@tsubakiky tsubakiky requested a review from Copilot May 1, 2025 10:58
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request adds support for the gRPC protocol alongside Connect with several refactoring updates to improve streaming responses (including trailer support) and protocol handler implementations. Key changes include:

  • Introducing gRPC constants and updating protocol header exclusion in the protocol module.
  • Refactoring Handler classes to replace function pointer checks with a stream type property.
  • Updating configuration files and client examples to support gRPC protocol and HTTP/2 trailers.

Reviewed Changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/connect/streaming_response.py New streaming response class with trailer support; potential initialization bug in media_type.
src/connect/protocol.py Added new gRPC constants and adjusted header exclusion logic (duplicate header entry).
src/connect/handler.py Refactored request handling to use stream_type and unified implementation method.
src/connect/error.py Added helper method details_any for error details.
src/connect/envelope.py Introduced EnvelopeWriter/Reader; minor typo in error message.
src/connect/connect.py Updated async stream handling and removed redundant connection protocols.
pyproject.toml Added googleapis-common-protos dependency.
examples/pyproject.toml Removed grpcio dependency to align with gRPC support through Connect.
examples/cmd/examples-go/client/main.go Updated client transport configuration to support gRPC over HTTP/2.
conformance/server_config.yaml Updated protocol list and trailer support configuration.
conformance/run-testcase.txt Updated test cases to reflect gRPC request handling changes.
conformance/pyproject.toml Updated hypercorn dependency to pull from Git.

@tsubakiky tsubakiky requested a review from Copilot May 1, 2025 11:04
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for the gRPC protocol alongside the existing Connect protocol while updating various components to handle streaming and unary messages more robustly. Key changes include:

  • Introduction of gRPC protocol constants and configuration updates.
  • Refactoring of handler and connection implementations to streamline stream and unary request processing.
  • Enhancements in envelope marshaling/unmarshaling and dependency updates.

Reviewed Changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/connect/streaming_response.py New StreamingResponse supporting trailers with minor header issues.
src/connect/protocol.py Added gRPC-related constants and updated protocol handler interfaces.
src/connect/handler.py Refactored handler implementation and streamlined timeout parsing.
src/connect/envelope.py Added EnvelopeWriter/Reader enhancements; updated data size checks.
src/connect/connect.py Updated connection abstractions and unary/stream message receiving.
pyproject.toml, examples/pyproject.toml Updated dependencies for gRPC support.
examples/cmd/examples-go/client/main.go Modified Go client for HTTP/2 and gRPC support.
conformance/* Updated config and test cases to reflect gRPC support.

@tsubakiky tsubakiky requested a review from Copilot May 1, 2025 11:08
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces support for the GRPC protocol across the project while enhancing and refactoring various connection and handler components.

  • Added new GRPC-related constants and updated protocol mappings.
  • Refactored handler implementations to use an async implementation method and removed legacy type‐checks.
  • Updated envelope writing/reading logic and example client configurations to incorporate GRPC support.

Reviewed Changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/connect/streaming_response.py Introduces streaming responses with trailer support and adjusts header initialization.
src/connect/protocol.py Adds GRPC and GRPC-Web protocol constants, and removes unused type definitions.
src/connect/handler.py Refactors handler classes by removing legacy type-check methods and integrating GRPC support via async implementation.
src/connect/error.py Adds a helper method for retrieving error details.
src/connect/envelope.py Implements envelope writer/reader functionality with compression support.
src/connect/connect.py Refactors connection interfaces and async message receiving functions.
pyproject.toml Adds dependency on googleapis-common-protos.
examples/pyproject.toml Updates dependencies for examples.
examples/cmd/examples-go/client/main.go Updates the client example to use an HTTP/2 transport with GRPC support.
conformance/* Modifies configurations and test cases to enable GRPC and trailer support.
Comments suppressed due to low confidence (1)

src/connect/handler.py:44

  • [nitpick] There appears to be a naming inconsistency: 'ProtocolGPRC' should probably be renamed to 'ProtocolGRPC' to align with the GRPC protocol naming used elsewhere.
from connect.protocol_grpc import ProtocolGPRC

@tsubakiky tsubakiky merged commit 9b4da73 into main May 1, 2025
2 checks passed
@tsubakiky tsubakiky deleted the unary-grpc-server branch May 1, 2025 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant