lizining1231 opened a new issue, #3814:
URL: https://github.com/apache/dubbo-go/issues/3814

   ### Summary
   
   Sub-issue of #3810
   
   Allow applications to select externally registered message serializers 
through the independent gRPC protocol, adapting public serialization 
registrations to grpc-go content subtypes.
   
   The parent issue covers shared contracts, configuration and Triple 
integration; Classic Dubbo is tracked separately. This sub-issue concerns 
`protocol/grpc`, which is separate from Triple's use of the gRPC wire format.
   
   ### Problem
   
   Registering a serialization plugin for Triple does not make it available to 
the independent gRPC implementation. Applications need a supported way to 
register a message serializer, select it through normal client configuration 
and use the matching gRPC content subtype on the server.
   
   The grpc-go subtype registry is process-wide. Treating it as a 
connection-local resource could silently replace another service's codec or 
reuse an incompatible configuration. The integration must therefore define 
registration conflicts and lifetime explicitly.
   
   ### Proposed Design
   
   #### 1. Adapt registered message codecs
   
   - Resolve `MessageMode` registrations for the `grpc` protocol through the 
public serialization registry.
   - Require the registered name and wire name to match, and install a stable 
adapter under that gRPC subtype.
   - Select the configured subtype through the public gRPC client, allowing the 
server to dispatch by content subtype.
   - Preserve existing Protobuf and `jsonpb` JSON behavior and leave standard 
subtype dispatch available.
   
   ```mermaid
   flowchart TD
       A[Public serialization registration] --> B[grpc MessageMode codec]
       B --> C[Validate subtype and configuration]
       C --> D[Process-wide grpc-go subtype adapter]
       E[Public client serialization option] --> F[Request content subtype]
       D --> G[Matching server decoder]
       F --> G
       G --> H[Business service]
   ```
   
   #### 2. Define process-wide configuration and lifetime
   
   - Reuse an installed subtype only when its configuration and namespaced 
parameters match.
   - Reject incompatible configuration or a subtype already registered outside 
this extension mechanism.
   - Permit retry after failed construction without publishing a broken 
registration.
   - Keep installed subtype resources for the process lifetime. Endpoint 
closure must not invalidate the global adapter.
   - Do not pass endpoint- or side-specific identity to factories for 
process-wide bindings.
   
   ### Scope and Compatibility
   
   This sub-issue includes the independent gRPC subtype adapter, public client 
selection, configuration conflict handling, initialization retry, regression 
tests and documentation. Preserve existing Protobuf, JSON and normal subtype 
dispatch behavior. Installed subtype instances have process lifetime.
   
   It depends only on the shared mechanism and configuration in #3810 and can 
merge independently of the Classic Dubbo integration after the shared/Triple PR 
is merged. Triple framing, Dubbo stream serialization, a concrete Fory plugin 
and performance optimization are outside this sub-issue.
   
   ### Acceptance Criteria
   
   1. A custom message codec completes RPC through a registered gRPC subtype.
   2. Selecting serialization through the public client applies the expected 
subtype.
   3. Protobuf and existing JSON behavior remain compatible.
   4. Conflicting configurations and external subtype registrations return 
errors rather than silently replace an existing codec.
   5. Failed initialization can be retried successfully.
   6. Subtype RPC, conflict, retry and compatibility tests pass, including 
targeted race checks.
   7. The PR includes implementation, tests and documentation of subtype 
configuration and process lifetime.
   
   ### Related Code
   
   These links describe the baseline before the proposed extension mechanism:
   
   | Area | Integration point |
   | --- | --- |
   | [Independent gRPC 
protocol](https://github.com/apache/dubbo-go/blob/6b04ac04bfc868060995dc9fa4e1dcc5138ad02b/protocol/grpc/grpc_protocol.go)
 | Protocol initialization and subtype adapter installation. |
   | [Independent gRPC 
client](https://github.com/apache/dubbo-go/blob/6b04ac04bfc868060995dc9fa4e1dcc5138ad02b/protocol/grpc/client.go)
 | Outgoing content-subtype selection. |
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to