Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: dubbo version #130

Merged
merged 2 commits into from
Sep 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ func packRequest(service Service, header DubboHeader, req interface{}) ([]byte,
err error
types string
byteArray []byte
version string
pkgLen int
)

Expand Down Expand Up @@ -220,8 +219,9 @@ func packRequest(service Service, header DubboHeader, req interface{}) ([]byte,
goto END
}

// https://github.com/apache/dubbo/blob/dubbo-2.7.1/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/support/header/HeaderExchangeChannel.java#L92
// dubbo version + path + version + method
encoder.Encode(DUBBO_VERSION)
encoder.Encode(DEFAULT_DUBBO_PROTOCOL_VERSION)
encoder.Encode(service.Path)
encoder.Encode(service.Version)
encoder.Encode(service.Method)
Expand All @@ -238,9 +238,8 @@ func packRequest(service Service, header DubboHeader, req interface{}) ([]byte,
request.Attachments[PATH_KEY] = service.Path
request.Attachments[GROUP_KEY] = service.Group
request.Attachments[INTERFACE_KEY] = service.Interface
if len(version) != 0 {
request.Attachments[VERSION_KEY] = version
}
request.Attachments[VERSION_KEY] = service.Version

if service.Timeout != 0 {
request.Attachments[TIMEOUT_KEY] = strconv.Itoa(int(service.Timeout / time.Millisecond))
}
Expand Down Expand Up @@ -325,6 +324,7 @@ func unpackRequestBody(decoder *Decoder, reqObj interface{}) error {
return perrors.WithStack(err)
}
if v, ok := attachments.(map[interface{}]interface{}); ok {
v[DUBBO_VERSION_KEY] = dubboVersion
req[6] = ToMapStringString(v)
return nil
}
Expand Down
7 changes: 2 additions & 5 deletions response.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ func EnsureResponse(body interface{}) *Response {
return NewResponse(body, nil, nil)
}

// dubbo-remoting/dubbo-remoting-api/src/main/java/com/alibaba/dubbo/remoting/exchange/codec/ExchangeCodec.java
// v2.7.1 line 256 encodeResponse
// https://github.com/apache/dubbo/blob/dubbo-2.7.1/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/codec/ExchangeCodec.java#L256
// hessian encode response
func packResponse(header DubboHeader, ret interface{}) ([]byte, error) {
var (
Expand Down Expand Up @@ -332,10 +331,8 @@ func ReflectResponse(in interface{}, out interface{}) error {

var versionInt = make(map[string]int)

// https://github.com/apache/dubbo/blob/dubbo-2.7.1/dubbo-common/src/main/java/org/apache/dubbo/common/Version.java#L96
// isSupportResponseAttachment is for compatibility among some dubbo version
// but we haven't used it yet.
// dubbo-common/src/main/java/org/apache/dubbo/common/Version.java
// v2.7.1 line 96
func isSupportResponseAttachment(version string) bool {
if version == "" {
return false
Expand Down