Skip to content
Snippets Groups Projects
Commit 075e8aa9 authored by Patrick's avatar Patrick
Browse files

Merge branch 'develop' into generic-service

parents 9f5afaeb 05c36892
No related branches found
No related tags found
No related merge requests found
......@@ -98,11 +98,11 @@ You can know more about dubbo-go by its [roadmap](https://github.com/apache/dubb
## Document
TODO
https://dubbogo.github.io/dubbo-go-website(**Improving**)
## Quick Start
[dubbogo-samples](https://github.com/dubbogo/dubbogo-samples) shows how to use dubbo-go. Please read the [dubbogo-samples/README.md](https://github.com/dubbogo/dubbogo-samples/blob/master/README.md) carefully to learn how to dispose the configuration and compile the program.
[dubbo-samples/golang](https://github.com/dubbogo/dubbo-samples) shows how to use dubbo-go. Please read the [dubbo-samples/golang/README.md](https://github.com/dubbogo/dubbo-samples/blob/master/golang/README.md) carefully to learn how to dispose the configuration and compile the program.
## Running unit tests
......
......@@ -97,11 +97,11 @@ Apache License, Version 2.0
## 文档
TODO
https://dubbogo.github.io/dubbo-go-website(**完善中**)
## 快速开始 ##
[dubbogo-samples](https://github.com/dubbogo/dubbogo-samples)这个项目的事例展示了如何使用 dubbo-go 。请仔细阅读 [dubbogo-samples/README.md](https://github.com/dubbogo/dubbogo-samples/blob/master/README.md) 学习如何处理配置并编译程序。
[dubbo-samples/golang](https://github.com/dubbogo/dubbo-samples)这个项目的事例展示了如何使用 dubbo-go 。请仔细阅读 [dubbo-samples/golang/README.md](https://github.com/dubbogo/dubbo-samples/blob/master/golang/README.md) 学习如何处理配置并编译程序。
## 运行单测
......
......@@ -47,22 +47,21 @@ type GenericFilter struct{}
func (ef *GenericFilter) Invoke(invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result {
if invocation.MethodName() == constant.GENERIC && len(invocation.Arguments()) == 3 {
oldArguments := invocation.Arguments()
var newParams []hessian.Object
if oldParams, ok := oldArguments[2].([]interface{}); ok {
newParams := make([]hessian.Object, 0, len(oldParams))
for i := range oldParams {
newParams = append(newParams, hessian.Object(struct2MapAll(oldParams[i])))
}
} else {
return invoker.Invoke(invocation)
}
newArguments := []interface{}{
oldArguments[0],
oldArguments[1],
newParams,
newArguments := []interface{}{
oldArguments[0],
oldArguments[1],
newParams,
}
newInvocation := invocation2.NewRPCInvocation(invocation.MethodName(), newArguments, invocation.Attachments())
newInvocation.SetReply(invocation.Reply())
return invoker.Invoke(newInvocation)
}
newInvocation := invocation2.NewRPCInvocation(invocation.MethodName(), newArguments, invocation.Attachments())
newInvocation.SetReply(invocation.Reply())
return invoker.Invoke(newInvocation)
}
return invoker.Invoke(invocation)
}
......
......@@ -19,6 +19,7 @@ package invocation
import (
"reflect"
"sync"
)
import (
......@@ -37,6 +38,7 @@ type RPCInvocation struct {
callBack interface{}
attachments map[string]string
invoker protocol.Invoker
lock sync.RWMutex
}
func NewRPCInvocation(methodName string, arguments []interface{}, attachments map[string]string) *RPCInvocation {
......@@ -80,6 +82,8 @@ func (r *RPCInvocation) Attachments() map[string]string {
}
func (r *RPCInvocation) AttachmentsByKey(key string, defaultValue string) string {
r.lock.RLock()
defer r.lock.RUnlock()
if r.attachments == nil {
return defaultValue
}
......@@ -91,6 +95,8 @@ func (r *RPCInvocation) AttachmentsByKey(key string, defaultValue string) string
}
func (r *RPCInvocation) SetAttachments(key string, value string) {
r.lock.Lock()
defer r.lock.Unlock()
if r.attachments == nil {
r.attachments = make(map[string]string)
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment