generated from cloudwego/.github
-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
It seems that enumeration is not supported now, but Hessian-dubbo already has support for int enumeration.
// POJO interface
// !!! Pls attention that Every field name should be upper case.
// Otherwise the app may panic.
type POJO interface {
JavaClassName() string // got a go struct's Java Class package name which should be a POJO class.
}
// POJOEnum enum for POJO
type POJOEnum interface {
POJO
String() string
EnumValue(string) JavaEnum
}
// JavaEnum type
type JavaEnum int32
// JavaEnumClass struct
type JavaEnumClass struct {
name string
}The writing method when using the hessian2 protocol conversion type normally is as follows:
type CompanyEnum hessian.JavaEnum
const (
Kigger CompanyEnum = 5
Zharhg CompanyEnum = 1
)
var companyName = map[CompanyEnum]string{
Kigger: "Kigger",
Zharhg : "Zharhg ",
}
var companyValue = map[string]CompanyEnum{
"Kigger": Kigger,
"Zharhg ": Zharhg ,
}
func (g CompanyEnum) JavaClassName() string {
return "xxxxxx"
}
func (g CompanyEnum) String() string {
s, ok := companyName[g]
if ok {
return s
}
return strconv.Itoa(int(g))
}
func (g CompanyEnum) EnumValue(s string) hessian.JavaEnum {
v, ok := companyValue[s]
if ok {
return hessian.JavaEnum(v)
}
return hessian.InvalidJavaEnum
}Because Codec-dubbo calls hessian-dubbo for serialization at the bottom level, the purpose can be achieved as long as the type can be guaranteed to be serialized by hessian-dubbo. For specific real-time solutions, you can refer to the implementation of extended thrift.
具体实现参考:
dubbo-go-hessian2
IDL-REF
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels