CAICAIIs opened a new pull request, #1054:
URL: https://github.com/apache/dubbo-go-pixiu/pull/1054

   <!--  Thanks for sending a pull request! 
   -->
   
   **What this PR does**:
   
   Adds `integrationRequest.generic` to the Dubbo backend config, so the 
generic invocation mode can be chosen per API:
   
   ```yaml
   integrationRequest:
     requestType: dubbo
     interface: com.example.Greeter
     method: SayHello
     protocol: tri
     serialization: hessian2
     generic: protobuf-json
     parameterTypes:
       - com.example.HelloRequest
     mappingParams:
       - name: requestBody.values
         mapTo: opt.values
   ```
   
   Before this change `pkg/client/dubbo` requested the map mode unconditionally 
(`dclient.WithGeneric()`), so `gson`, `protobuf-json` and `bean` could not be 
selected from configuration even though dubbo-go supports them, and a gateway 
that needs to call a protobuf defined service without generated code had no way 
to express it.
   
   Mode behaviour:
   
   | `generic` | Request | Response |
   | --- | --- | --- |
   | `"true"` (default) | `values` are sent as typed arguments, `types` carries 
the Java type of each one | map, as today |
   | `gson` | the whole request message is sent as JSON text; exactly one 
argument and one declared parameter type | JSON text, written to the HTTP 
response as a JSON body |
   | `protobuf-json` | same shape, with protobuf JSON mapping | same |
   | `bean` | Java bean compatible mode | as today |
   
   Files:
   
   | Location | Change |
   | --- | --- |
   | `pkg/config/api_config.go` | `DubboBackendConfig.Generic` |
   | `pkg/client/dubbo/generic.go` (new) | mode normalization, JSON text 
encoding and result unwrapping |
   | `pkg/client/dubbo/dubbo.go` | `WithGenericType` replaces `WithGeneric`, 
the mode joins the reference cache key |
   | `pkg/client/dubbo/types.go` | `DubboOutboundRequest.Generic` |
   | `pkg/filter/http/remote/dubbo_handler.go` | reads and validates the mode, 
renders the single JSON text argument for the JSON text modes, skips the Java 
scalar conversion there |
   | `pkg/filter/http/remote/call.go` | writes a JSON text result as a JSON 
body instead of a quoted string |
   | `pkg/adapter/dubboregistry/registry/registry.go` | generated APIs carry 
the default mode explicitly |
   | `pkg/common/constant/key.go` | the four mode names |
   | `docs/sample/dubbo/dubbo-universality.md`, 
`docs/sample/zh-cn/dubbo/dubbo-universality.md` | mode documentation, JSON text 
contract, provider requirements |
   
   **Which issue(s) this PR fixes**:
   
   Related: #709, #918. This is the pixiu side of the generic invocation 
upgrade; the dubbo-go side that registers the `$invoke` entry for IDL exported 
triple services landed in apache/dubbo-go#3752.
   
   **Special notes for your reviewer**:
   
   - An unknown `generic` value is rejected with the field named, instead of 
falling back to the map mode. A silent fallback would change the request 
contract without telling the caller, and dubbo-go's own generic mode validation 
only exists in newer releases than the pinned `v3.3.2-20260419`.
   - `saveServiceInfo` and the reference cache key: the mode is part of 
`genericServiceKey`, so one interface used with two modes gets two references 
instead of sharing one.
   - The JSON text modes keep the existing rule that direct mode requires 
`parameterTypes`; the declared type describes the request message and is 
informational on the provider side, which derives the argument type from the 
method signature.
   - Serving generic calls over Triple still requires the provider to declare 
`serialization: hessian2` and to expose `$invoke`. Both are documented in the 
two universality documents; the second one needs apache/dubbo-go#3752 for IDL 
exported providers.
   - I have not added an end-to-end sample for the JSON text modes yet; that 
belongs with the samples repository change, and this PR is opened as a draft 
until the mode plumbing is reviewed.
   
   **Does this PR introduce a user-facing change?**:
   
   ```release-note
   pixiu: `integrationRequest.generic` selects the generic invocation mode 
(`true`, `gson`, `protobuf-json`, `bean`). The `gson` and `protobuf-json` modes 
send the request message as JSON text, accept exactly one argument and one 
declared parameter type, and return their JSON result as a JSON body. 
Configurations that do not set the field keep the map mode.
   ```
   


-- 
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