NeverENG commented on code in PR #3500:
URL: https://github.com/apache/dubbo-go/pull/3500#discussion_r3640592076


##########
internal/config.go:
##########
@@ -215,3 +215,23 @@ func ValidateRegistryIDs(ids []string, regs 
map[string]*global.RegistryConfig) e
        }
        return nil
 }
+
+// ValidateGenericType validates the generic serialization type (generic mode).
+// An empty value means the call is not generic and is allowed. Unknown values 
fail
+// fast instead of silently falling back to the Map generalizer.
+//
+// Valid values: "true" (Map, default), "gson", "protobuf-json", "bean".
+// "protobuf" is kept as a legacy compatibility value and is not recommended.
+func ValidateGenericType(generic string) error {
+       switch {
+       case generic == "",
+               strings.EqualFold(generic, 
constant.GenericSerializationDefault),
+               strings.EqualFold(generic, constant.GenericSerializationGson),
+               strings.EqualFold(generic, 
constant.GenericSerializationProtobufJson),
+               strings.EqualFold(generic, constant.GenericSerializationBean),

Review Comment:
   已修复。抽出共享判定 `internal.IsGenericMode`,让 `ValidateGenericType` 与 
`protocol/triple/triple.go:isGenericCall` 共用同一套模式集合,Triple 现在识别 `bean` 并路由到支持 
`$invoke` 的 `NewTripleInvoker`。Triple 原有的 `true/gson/protobuf/protobuf-json` 
保持不变,仅新增 `bean`。已在 `Test_isGenericCall` 补充 `bean`(含大小写)用例,`go test ./internal/ 
./protocol/triple/` 通过。
   
   `filter/generic/util.go:isGeneric` 暂未接入共享判定:它不含 legacy `protobuf`,直接接入会静默把 
`protobuf` 引入 filter 路径、改变其行为,属于另一 owner 的 slice,故连同 `protobuf` 弃用决定一起作为 
follow-up 跟踪(见 PR 描述表格)。commit: bd5543d4。



##########
client/client.go:
##########
@@ -135,6 +135,19 @@ func (cli *Client) NewService(service any, opts 
...ReferenceOption) (*Connection
 // NewGenericService creates a GenericService for making generic calls without 
pre-generated stubs.
 // The referenceStr parameter specifies the service interface name (e.g., 
"org.apache.dubbo.samples.UserProvider").
 //
+// Defaults:
+//   - generic mode (generalization format): "true" (Map). Override with 
client.WithGenericType.
+//   - transport serialization: Hessian2. Override with 
client.WithSerialization.
+//
+// The generic mode and the transport serialization are two independent 
settings:
+// the former decides how objects are generalized, the latter how they are 
encoded on
+// the wire. Passing an unknown generic mode returns an error instead of 
silently
+// falling back to the Map generalizer.
+//
+// Whether the "class" field is kept in Map (generic=true) results is 
controlled by
+// the global "generic.include.class" configuration (default true). It only 
affects
+// the Map generalizer and currently has no per-reference override.

Review Comment:
   采用「收缩 scope」这一选项。`WithGenericIncludeClass` 已删除,`generic.include.class` 
保持**仅全局配置**并在 `client/client.go` 文档中说明其范围(Map-only、无 per-reference override)。PR 
描述的 Changes / Acceptance criteria 已同步更新:per-reference API 一项标记为 scoped 
out,不再声称已实现;同时新增了「Triple 识别 `bean` 并路由到 `$invoke` invoker」的验收项。本 PR 未在代码中实现 
per-reference 链路,留待生成器读取该参数后再补。



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