AlexStocks commented on code in PR #3501:
URL: https://github.com/apache/dubbo-go/pull/3501#discussion_r3630150641
##########
filter/generic/util.go:
##########
@@ -52,27 +50,71 @@ func isMakingAGenericCall(invoker base.Invoker, invocation
base.Invocation) bool
// isGeneric receives a generic field from url of invoker to determine whether
the service is generic or not
func isGeneric(generic string) bool {
- return strings.EqualFold(generic, constant.GenericSerializationDefault)
||
- strings.EqualFold(generic, constant.GenericSerializationGson) ||
- strings.EqualFold(generic,
constant.GenericSerializationProtobufJson) ||
- strings.EqualFold(generic, constant.GenericSerializationBean)
+ _, err := getGeneralizer(generic)
+ return err == nil
+}
+
+func isGenericDisabled(generic string) bool {
+ return generic == "" || strings.EqualFold(generic, "false")
}
-func getGeneralizer(generic string) (g generalizer.Generalizer) {
+// getGeneralizer resolves a generic mode to its generalizer.
+// Recommended modes are true, gson, bean, and protobuf-json. protobuf is
+// accepted as a legacy alias of protobuf-json for compatibility.
+func getGeneralizer(generic string) (generalizer.Generalizer, error) {
switch {
case strings.EqualFold(generic, constant.GenericSerializationDefault):
- g = generalizer.GetMapGeneralizer()
+ return generalizer.GetMapGeneralizer(), nil
case strings.EqualFold(generic, constant.GenericSerializationGson):
- g = generalizer.GetGsonGeneralizer()
- case strings.EqualFold(generic,
constant.GenericSerializationProtobufJson):
- g = generalizer.GetProtobufJsonGeneralizer()
+ return generalizer.GetGsonGeneralizer(), nil
+ case strings.EqualFold(generic,
constant.GenericSerializationProtobufJson),
+ strings.EqualFold(generic,
constant.GenericSerializationProtobuf):
Review Comment:
[P1] 不要把 legacy `protobuf` 直接映射为 `protobuf-json`
`generic=protobuf` 目前还是 Triple generic invoker/外层 protobuf wrapper
使用的历史标记,内部 `$invoke` 参数仍可能是 Hessian2 对象,并不等价于 protobuf JSON。用同一个
`$invoke`(attachment 为 `protobuf`、实参为 Hessian 字符串 `world`)做 Base/Head
overlay:Base `b87881aa` 能调用下游;当前 Head `97894301` 在这里选择
`ProtobufJsonGeneralizer` 后报 `the type of obj(=string) should be
proto.Message`,下游未被调用。建议保留该历史模式原有的 Map/Hessian 语义,或拆分 transport marker 与
generalizer mode;同时补一条真实 Triple `$invoke` 的兼容回归测试,而不是只验证 `protobuf` 与
`protobuf-json` 返回同一 generalizer。
--
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]