Skip to content
Snippets Groups Projects
Commit 2dd44a2d authored by AlexStocks's avatar AlexStocks
Browse files

Fix: Id -> ID

parent 6b12856c
No related branches found
No related tags found
No related merge requests found
Showing
with 91 additions and 91 deletions
...@@ -340,7 +340,7 @@ func createInstance(url *common.URL) (registry.ServiceInstance, error) { ...@@ -340,7 +340,7 @@ func createInstance(url *common.URL) (registry.ServiceInstance, error) {
ServiceName: appConfig.Name, ServiceName: appConfig.Name,
Host: host, Host: host,
Port: int(port), Port: int(port),
Id: host + constant.KEY_SEPARATOR + url.Port, ID: host + constant.KEY_SEPARATOR + url.Port,
Enable: true, Enable: true,
Healthy: true, Healthy: true,
Metadata: metadata, Metadata: metadata,
......
...@@ -46,7 +46,7 @@ type ReferenceConfig struct { ...@@ -46,7 +46,7 @@ type ReferenceConfig struct {
id string id string
InterfaceName string `required:"true" yaml:"interface" json:"interface,omitempty" property:"interface"` InterfaceName string `required:"true" yaml:"interface" json:"interface,omitempty" property:"interface"`
Check *bool `yaml:"check" json:"check,omitempty" property:"check"` Check *bool `yaml:"check" json:"check,omitempty" property:"check"`
Url string `yaml:"url" json:"url,omitempty" property:"url"` URL string `yaml:"url" json:"url,omitempty" property:"url"`
Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"` Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"`
Protocol string `default:"dubbo" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` Protocol string `default:"dubbo" yaml:"protocol" json:"protocol,omitempty" property:"protocol"`
Registry string `yaml:"registry" json:"registry,omitempty" property:"registry"` Registry string `yaml:"registry" json:"registry,omitempty" property:"registry"`
...@@ -94,40 +94,40 @@ func (c *ReferenceConfig) Refer(_ interface{}) { ...@@ -94,40 +94,40 @@ func (c *ReferenceConfig) Refer(_ interface{}) {
cfgURL := common.NewURLWithOptions( cfgURL := common.NewURLWithOptions(
common.WithPath(c.InterfaceName), common.WithPath(c.InterfaceName),
common.WithProtocol(c.Protocol), common.WithProtocol(c.Protocol),
common.WithParams(c.getUrlMap()), common.WithParams(c.getURLMap()),
common.WithParamsValue(constant.BEAN_NAME_KEY, c.id), common.WithParamsValue(constant.BEAN_NAME_KEY, c.id),
) )
if c.ForceTag { if c.ForceTag {
cfgURL.AddParam(constant.ForceUseTag, "true") cfgURL.AddParam(constant.ForceUseTag, "true")
} }
c.postProcessConfig(cfgURL) c.postProcessConfig(cfgURL)
if c.Url != "" { if c.URL != "" {
// 1. user specified URL, could be peer-to-peer address, or register center's address. // 1. user specified URL, could be peer-to-peer address, or register center's address.
urlStrings := gxstrings.RegSplit(c.Url, "\\s*[;]+\\s*") urlStrings := gxstrings.RegSplit(c.URL, "\\s*[;]+\\s*")
for _, urlStr := range urlStrings { for _, urlStr := range urlStrings {
serviceUrl, err := common.NewURL(urlStr) serviceURL, err := common.NewURL(urlStr)
if err != nil { if err != nil {
panic(fmt.Sprintf("user specified URL %v refer error, error message is %v ", urlStr, err.Error())) panic(fmt.Sprintf("user specified URL %v refer error, error message is %v ", urlStr, err.Error()))
} }
if serviceUrl.Protocol == constant.REGISTRY_PROTOCOL { if serviceURL.Protocol == constant.REGISTRY_PROTOCOL {
serviceUrl.SubURL = cfgURL serviceURL.SubURL = cfgURL
c.urls = append(c.urls, serviceUrl) c.urls = append(c.urls, serviceURL)
} else { } else {
if serviceUrl.Path == "" { if serviceURL.Path == "" {
serviceUrl.Path = "/" + c.InterfaceName serviceURL.Path = "/" + c.InterfaceName
} }
// merge url need to do // merge url need to do
newUrl := common.MergeUrl(serviceUrl, cfgURL) newURL := common.MergeURL(serviceURL, cfgURL)
c.urls = append(c.urls, newUrl) c.urls = append(c.urls, newURL)
} }
} }
} else { } else {
// 2. assemble SubURL from register center's configuration mode // 2. assemble SubURL from register center's configuration mode
c.urls = loadRegistries(c.Registry, consumerConfig.Registries, common.CONSUMER) c.urls = loadRegistries(c.Registry, consumerConfig.Registries, common.CONSUMER)
// set url to regUrls // set url to regURLs
for _, regUrl := range c.urls { for _, regURL := range c.urls {
regUrl.SubURL = cfgURL regURL.SubURL = cfgURL
} }
} }
...@@ -135,24 +135,24 @@ func (c *ReferenceConfig) Refer(_ interface{}) { ...@@ -135,24 +135,24 @@ func (c *ReferenceConfig) Refer(_ interface{}) {
c.invoker = extension.GetProtocol(c.urls[0].Protocol).Refer(c.urls[0]) c.invoker = extension.GetProtocol(c.urls[0].Protocol).Refer(c.urls[0])
} else { } else {
invokers := make([]protocol.Invoker, 0, len(c.urls)) invokers := make([]protocol.Invoker, 0, len(c.urls))
var regUrl *common.URL var regURL *common.URL
for _, u := range c.urls { for _, u := range c.urls {
invokers = append(invokers, extension.GetProtocol(u.Protocol).Refer(u)) invokers = append(invokers, extension.GetProtocol(u.Protocol).Refer(u))
if u.Protocol == constant.REGISTRY_PROTOCOL { if u.Protocol == constant.REGISTRY_PROTOCOL {
regUrl = u regURL = u
} }
} }
// TODO(decouple from directory, config should not depend on directory module) // TODO(decouple from directory, config should not depend on directory module)
var hitClu string var hitClu string
if regUrl != nil { if regURL != nil {
// for multi-subscription scenario, use 'zone-aware' policy by default // for multi-subscription scenario, use 'zone-aware' policy by default
hitClu = constant.ZONEAWARE_CLUSTER_NAME hitClu = constant.ZONEAWARE_CLUSTER_NAME
} else { } else {
// not a registry url, must be direct invoke. // not a registry url, must be direct invoke.
hitClu = constant.FAILOVER_CLUSTER_NAME hitClu = constant.FAILOVER_CLUSTER_NAME
if len(invokers) > 0 { if len(invokers) > 0 {
u := invokers[0].GetUrl() u := invokers[0].GetURL()
if nil != &u { if nil != &u {
hitClu = u.GetParam(constant.CLUSTER_KEY, constant.ZONEAWARE_CLUSTER_NAME) hitClu = u.GetParam(constant.CLUSTER_KEY, constant.ZONEAWARE_CLUSTER_NAME)
} }
...@@ -192,7 +192,7 @@ func (c *ReferenceConfig) GetProxy() *proxy.Proxy { ...@@ -192,7 +192,7 @@ func (c *ReferenceConfig) GetProxy() *proxy.Proxy {
return c.pxy return c.pxy
} }
func (c *ReferenceConfig) getUrlMap() url.Values { func (c *ReferenceConfig) getURLMap() url.Values {
urlMap := url.Values{} urlMap := url.Values{}
// first set user params // first set user params
for k, v := range c.Params { for k, v := range c.Params {
......
...@@ -235,7 +235,7 @@ func TestReferP2P(t *testing.T) { ...@@ -235,7 +235,7 @@ func TestReferP2P(t *testing.T) {
doInitConsumer() doInitConsumer()
extension.SetProtocol("dubbo", GetProtocol) extension.SetProtocol("dubbo", GetProtocol)
m := consumerConfig.References["MockService"] m := consumerConfig.References["MockService"]
m.Url = "dubbo://127.0.0.1:20000" m.URL = "dubbo://127.0.0.1:20000"
for _, reference := range consumerConfig.References { for _, reference := range consumerConfig.References {
reference.Refer(nil) reference.Refer(nil)
...@@ -249,7 +249,7 @@ func TestReferMultiP2P(t *testing.T) { ...@@ -249,7 +249,7 @@ func TestReferMultiP2P(t *testing.T) {
doInitConsumer() doInitConsumer()
extension.SetProtocol("dubbo", GetProtocol) extension.SetProtocol("dubbo", GetProtocol)
m := consumerConfig.References["MockService"] m := consumerConfig.References["MockService"]
m.Url = "dubbo://127.0.0.1:20000;dubbo://127.0.0.2:20000" m.URL = "dubbo://127.0.0.1:20000;dubbo://127.0.0.2:20000"
for _, reference := range consumerConfig.References { for _, reference := range consumerConfig.References {
reference.Refer(nil) reference.Refer(nil)
...@@ -264,7 +264,7 @@ func TestReferMultiP2PWithReg(t *testing.T) { ...@@ -264,7 +264,7 @@ func TestReferMultiP2PWithReg(t *testing.T) {
extension.SetProtocol("dubbo", GetProtocol) extension.SetProtocol("dubbo", GetProtocol)
extension.SetProtocol("registry", GetProtocol) extension.SetProtocol("registry", GetProtocol)
m := consumerConfig.References["MockService"] m := consumerConfig.References["MockService"]
m.Url = "dubbo://127.0.0.1:20000;registry://127.0.0.2:20000" m.URL = "dubbo://127.0.0.1:20000;registry://127.0.0.2:20000"
for _, reference := range consumerConfig.References { for _, reference := range consumerConfig.References {
reference.Refer(nil) reference.Refer(nil)
...@@ -292,11 +292,11 @@ func TestForking(t *testing.T) { ...@@ -292,11 +292,11 @@ func TestForking(t *testing.T) {
extension.SetProtocol("dubbo", GetProtocol) extension.SetProtocol("dubbo", GetProtocol)
extension.SetProtocol("registry", GetProtocol) extension.SetProtocol("registry", GetProtocol)
m := consumerConfig.References["MockService"] m := consumerConfig.References["MockService"]
m.Url = "dubbo://127.0.0.1:20000;registry://127.0.0.2:20000" m.URL = "dubbo://127.0.0.1:20000;registry://127.0.0.2:20000"
for _, reference := range consumerConfig.References { for _, reference := range consumerConfig.References {
reference.Refer(nil) reference.Refer(nil)
forks := int(reference.invoker.GetUrl().GetParamInt(constant.FORKS_KEY, constant.DEFAULT_FORKS)) forks := int(reference.invoker.GetURL().GetParamInt(constant.FORKS_KEY, constant.DEFAULT_FORKS))
assert.Equal(t, 5, forks) assert.Equal(t, 5, forks)
assert.NotNil(t, reference.pxy) assert.NotNil(t, reference.pxy)
assert.NotNil(t, reference.Cluster) assert.NotNil(t, reference.Cluster)
...@@ -309,16 +309,16 @@ func TestSticky(t *testing.T) { ...@@ -309,16 +309,16 @@ func TestSticky(t *testing.T) {
extension.SetProtocol("dubbo", GetProtocol) extension.SetProtocol("dubbo", GetProtocol)
extension.SetProtocol("registry", GetProtocol) extension.SetProtocol("registry", GetProtocol)
m := consumerConfig.References["MockService"] m := consumerConfig.References["MockService"]
m.Url = "dubbo://127.0.0.1:20000;registry://127.0.0.2:20000" m.URL = "dubbo://127.0.0.1:20000;registry://127.0.0.2:20000"
reference := consumerConfig.References["MockService"] reference := consumerConfig.References["MockService"]
reference.Refer(nil) reference.Refer(nil)
referenceSticky := reference.invoker.GetUrl().GetParam(constant.STICKY_KEY, "false") referenceSticky := reference.invoker.GetURL().GetParam(constant.STICKY_KEY, "false")
assert.Equal(t, "false", referenceSticky) assert.Equal(t, "false", referenceSticky)
method0StickKey := reference.invoker.GetUrl().GetMethodParam(reference.Methods[0].Name, constant.STICKY_KEY, "false") method0StickKey := reference.invoker.GetURL().GetMethodParam(reference.Methods[0].Name, constant.STICKY_KEY, "false")
assert.Equal(t, "false", method0StickKey) assert.Equal(t, "false", method0StickKey)
method1StickKey := reference.invoker.GetUrl().GetMethodParam(reference.Methods[1].Name, constant.STICKY_KEY, "false") method1StickKey := reference.invoker.GetURL().GetMethodParam(reference.Methods[1].Name, constant.STICKY_KEY, "false")
assert.Equal(t, "true", method1StickKey) assert.Equal(t, "true", method1StickKey)
} }
...@@ -340,13 +340,13 @@ func (*mockRegistryProtocol) Refer(url *common.URL) protocol.Invoker { ...@@ -340,13 +340,13 @@ func (*mockRegistryProtocol) Refer(url *common.URL) protocol.Invoker {
} }
func (*mockRegistryProtocol) Export(invoker protocol.Invoker) protocol.Exporter { func (*mockRegistryProtocol) Export(invoker protocol.Invoker) protocol.Exporter {
registryUrl := getRegistryUrl(invoker) registryURL := getRegistryURL(invoker)
if registryUrl.Protocol == "service-discovery" { if registryURL.Protocol == "service-discovery" {
metaDataService, err := extension.GetMetadataService(GetApplicationConfig().MetadataType) metaDataService, err := extension.GetMetadataService(GetApplicationConfig().MetadataType)
if err != nil { if err != nil {
panic(err) panic(err)
} }
ok, err := metaDataService.ExportURL(invoker.GetUrl().SubURL.Clone()) ok, err := metaDataService.ExportURL(invoker.GetURL().SubURL.Clone())
if err != nil { if err != nil {
panic(err) panic(err)
} }
...@@ -361,9 +361,9 @@ func (*mockRegistryProtocol) Destroy() { ...@@ -361,9 +361,9 @@ func (*mockRegistryProtocol) Destroy() {
// Destroy is a mock function // Destroy is a mock function
} }
func getRegistryUrl(invoker protocol.Invoker) *common.URL { func getRegistryURL(invoker protocol.Invoker) *common.URL {
// here add * for return a new url // here add * for return a new url
url := invoker.GetUrl() url := invoker.GetURL()
// if the protocol == registry ,set protocol the registry value in url.params // if the protocol == registry ,set protocol the registry value in url.params
if url.Protocol == constant.REGISTRY_PROTOCOL { if url.Protocol == constant.REGISTRY_PROTOCOL {
protocol := url.GetParam(constant.REGISTRY_KEY, "") protocol := url.GetParam(constant.REGISTRY_KEY, "")
......
...@@ -182,8 +182,8 @@ func (n *nacosDynamicConfiguration) GetDone() chan struct{} { ...@@ -182,8 +182,8 @@ func (n *nacosDynamicConfiguration) GetDone() chan struct{} {
return n.done return n.done
} }
// GetUrl Get Url // GetURL Get URL
func (n *nacosDynamicConfiguration) GetUrl() *common.URL { func (n *nacosDynamicConfiguration) GetURL() *common.URL {
return n.url return n.url
} }
......
...@@ -44,7 +44,7 @@ func TestDefaultAuthenticator_Authenticate(t *testing.T) { ...@@ -44,7 +44,7 @@ func TestDefaultAuthenticator_Authenticate(t *testing.T) {
testurl.SetParam(constant.SECRET_ACCESS_KEY_KEY, secret) testurl.SetParam(constant.SECRET_ACCESS_KEY_KEY, secret)
parmas := []interface{}{"OK", struct { parmas := []interface{}{"OK", struct {
Name string Name string
Id int64 ID int64
}{"YUYU", 1}} }{"YUYU", 1}}
inv := invocation.NewRPCInvocation("test", parmas, nil) inv := invocation.NewRPCInvocation("test", parmas, nil)
requestTime := strconv.Itoa(int(time.Now().Unix() * 1000)) requestTime := strconv.Itoa(int(time.Now().Unix() * 1000))
......
...@@ -47,7 +47,7 @@ func TestProviderAuthFilter_Invoke(t *testing.T) { ...@@ -47,7 +47,7 @@ func TestProviderAuthFilter_Invoke(t *testing.T) {
"OK", "OK",
struct { struct {
Name string Name string
Id int64 ID int64
}{"YUYU", 1}, }{"YUYU", 1},
} }
inv := invocation.NewRPCInvocation("test", parmas, nil) inv := invocation.NewRPCInvocation("test", parmas, nil)
......
...@@ -64,7 +64,7 @@ func TestSignWithParams(t *testing.T) { ...@@ -64,7 +64,7 @@ func TestSignWithParams(t *testing.T) {
params := []interface{}{ params := []interface{}{
"a", 1, struct { "a", 1, struct {
Name string Name string
Id int64 ID int64
}{"YuYu", 1}, }{"YuYu", 1},
} }
signature, _ := SignWithParams(params, metadata, key) signature, _ := SignWithParams(params, metadata, key)
...@@ -84,13 +84,13 @@ func Test_toBytes(t *testing.T) { ...@@ -84,13 +84,13 @@ func Test_toBytes(t *testing.T) {
params := []interface{}{ params := []interface{}{
"a", 1, struct { "a", 1, struct {
Name string Name string
Id int64 ID int64
}{"YuYu", 1}, }{"YuYu", 1},
} }
params2 := []interface{}{ params2 := []interface{}{
"a", 1, struct { "a", 1, struct {
Name string Name string
Id int64 ID int64
}{"YuYu", 1}, }{"YuYu", 1},
} }
jsonBytes, _ := toBytes(params) jsonBytes, _ := toBytes(params)
......
...@@ -57,13 +57,13 @@ func (def *ServiceDefinition) String() string { ...@@ -57,13 +57,13 @@ func (def *ServiceDefinition) String() string {
} }
var param strings.Builder var param strings.Builder
for _, d := range m.Parameters { for _, d := range m.Parameters {
param.WriteString(fmt.Sprintf("{id:%v,type:%v,builderName:%v}", d.Id, d.Type, d.TypeBuilderName)) param.WriteString(fmt.Sprintf("{id:%v,type:%v,builderName:%v}", d.ID, d.Type, d.TypeBuilderName))
} }
methodStr.WriteString(fmt.Sprintf("{name:%v,parameterTypes:[%v],returnType:%v,params:[%v] }", m.Name, paramType.String(), m.ReturnType, param.String())) methodStr.WriteString(fmt.Sprintf("{name:%v,parameterTypes:[%v],returnType:%v,params:[%v] }", m.Name, paramType.String(), m.ReturnType, param.String()))
} }
var types strings.Builder var types strings.Builder
for _, d := range def.Types { for _, d := range def.Types {
types.WriteString(fmt.Sprintf("{id:%v,type:%v,builderName:%v}", d.Id, d.Type, d.TypeBuilderName)) types.WriteString(fmt.Sprintf("{id:%v,type:%v,builderName:%v}", d.ID, d.Type, d.TypeBuilderName))
} }
return fmt.Sprintf("{canonicalName:%v, codeSource:%v, methods:[%v], types:[%v]}", def.CanonicalName, def.CodeSource, methodStr.String(), types.String()) return fmt.Sprintf("{canonicalName:%v, codeSource:%v, methods:[%v], types:[%v]}", def.CanonicalName, def.CodeSource, methodStr.String(), types.String())
} }
...@@ -84,7 +84,7 @@ type MethodDefinition struct { ...@@ -84,7 +84,7 @@ type MethodDefinition struct {
// TypeDefinition is the describer of type definition // TypeDefinition is the describer of type definition
type TypeDefinition struct { type TypeDefinition struct {
Id string ID string
Type string Type string
Items []TypeDefinition Items []TypeDefinition
Enums []string Enums []string
......
...@@ -23,7 +23,7 @@ import ( ...@@ -23,7 +23,7 @@ import (
) )
type User struct { type User struct {
Id string ID string
Name string Name string
Age int32 Age int32
Time time.Time Time time.Time
......
...@@ -47,7 +47,7 @@ func TestCreateProxy(t *testing.T) { ...@@ -47,7 +47,7 @@ func TestCreateProxy(t *testing.T) {
return &mockProtocol{} return &mockProtocol{}
}) })
ins := &registry.DefaultServiceInstance{ ins := &registry.DefaultServiceInstance{
Id: "test-id", ID: "test-id",
ServiceName: "com.dubbo", ServiceName: "com.dubbo",
Host: "localhost", Host: "localhost",
Port: 8080, Port: 8080,
......
...@@ -81,7 +81,7 @@ func createPxy() service.MetadataService { ...@@ -81,7 +81,7 @@ func createPxy() service.MetadataService {
}) })
ins := &registry.DefaultServiceInstance{ ins := &registry.DefaultServiceInstance{
Id: "test-id", ID: "test-id",
ServiceName: "com.dubbo", ServiceName: "com.dubbo",
Host: "localhost", Host: "localhost",
Port: 8080, Port: 8080,
......
...@@ -83,7 +83,7 @@ func createProxy() service.MetadataService { ...@@ -83,7 +83,7 @@ func createProxy() service.MetadataService {
prepareTest() prepareTest()
ins := &registry.DefaultServiceInstance{ ins := &registry.DefaultServiceInstance{
Id: "test-id", ID: "test-id",
ServiceName: "com.dubbo", ServiceName: "com.dubbo",
Host: "localhost", Host: "localhost",
Port: 8080, Port: 8080,
...@@ -110,34 +110,34 @@ func (m *mockMetadataReportFactory) CreateMetadataReport(*common.URL) report.Met ...@@ -110,34 +110,34 @@ func (m *mockMetadataReportFactory) CreateMetadataReport(*common.URL) report.Met
type mockMetadataReport struct{} type mockMetadataReport struct{}
func (m mockMetadataReport) StoreProviderMetadata(*identifier.MetadataIdentifier, string) error { func (m mockMetadataReport) StoreProviderMetadata(*identifier.MetadataIDentifier, string) error {
panic("implement me") panic("implement me")
} }
func (m mockMetadataReport) StoreConsumerMetadata(*identifier.MetadataIdentifier, string) error { func (m mockMetadataReport) StoreConsumerMetadata(*identifier.MetadataIDentifier, string) error {
panic("implement me") panic("implement me")
} }
func (m mockMetadataReport) SaveServiceMetadata(*identifier.ServiceMetadataIdentifier, *common.URL) error { func (m mockMetadataReport) SaveServiceMetadata(*identifier.ServiceMetadataIDentifier, *common.URL) error {
return nil return nil
} }
func (m mockMetadataReport) RemoveServiceMetadata(*identifier.ServiceMetadataIdentifier) error { func (m mockMetadataReport) RemoveServiceMetadata(*identifier.ServiceMetadataIDentifier) error {
panic("implement me") panic("implement me")
} }
func (m mockMetadataReport) GetExportedURLs(*identifier.ServiceMetadataIdentifier) ([]string, error) { func (m mockMetadataReport) GetExportedURLs(*identifier.ServiceMetadataIDentifier) ([]string, error) {
return []string{"mock://localhost1", "mock://localhost2"}, nil return []string{"mock://localhost1", "mock://localhost2"}, nil
} }
func (m mockMetadataReport) SaveSubscribedData(*identifier.SubscriberMetadataIdentifier, string) error { func (m mockMetadataReport) SaveSubscribedData(*identifier.SubscriberMetadataIDentifier, string) error {
return nil return nil
} }
func (m mockMetadataReport) GetSubscribedURLs(*identifier.SubscriberMetadataIdentifier) ([]string, error) { func (m mockMetadataReport) GetSubscribedURLs(*identifier.SubscriberMetadataIDentifier) ([]string, error) {
panic("implement me") panic("implement me")
} }
func (m mockMetadataReport) GetServiceDefinition(*identifier.MetadataIdentifier) (string, error) { func (m mockMetadataReport) GetServiceDefinition(*identifier.MetadataIDentifier) (string, error) {
return "definition", nil return "definition", nil
} }
...@@ -56,7 +56,7 @@ func TestDubboInvokerInvoke(t *testing.T) { ...@@ -56,7 +56,7 @@ func TestDubboInvokerInvoke(t *testing.T) {
// Call // Call
res := invoker.Invoke(context.Background(), inv) res := invoker.Invoke(context.Background(), inv)
assert.NoError(t, res.Error()) assert.NoError(t, res.Error())
assert.Equal(t, User{Id: "1", Name: "username"}, *res.Result().(*User)) assert.Equal(t, User{ID: "1", Name: "username"}, *res.Result().(*User))
// CallOneway // CallOneway
inv.SetAttachments(constant.ASYNC_KEY, "true") inv.SetAttachments(constant.ASYNC_KEY, "true")
...@@ -69,7 +69,7 @@ func TestDubboInvokerInvoke(t *testing.T) { ...@@ -69,7 +69,7 @@ func TestDubboInvokerInvoke(t *testing.T) {
inv.SetCallBack(func(response common.CallbackResponse) { inv.SetCallBack(func(response common.CallbackResponse) {
r := response.(remoting.AsyncCallbackResponse) r := response.(remoting.AsyncCallbackResponse)
rst := *r.Reply.(*remoting.Response).Result.(*protocol.RPCResult) rst := *r.Reply.(*remoting.Response).Result.(*protocol.RPCResult)
assert.Equal(t, User{Id: "1", Name: "username"}, *(rst.Rest.(*User))) assert.Equal(t, User{ID: "1", Name: "username"}, *(rst.Rest.(*User)))
// assert.Equal(t, User{ID: "1", Name: "username"}, *r.Reply.(*Response).reply.(*User)) // assert.Equal(t, User{ID: "1", Name: "username"}, *r.Reply.(*Response).reply.(*User))
lock.Unlock() lock.Unlock()
}) })
...@@ -164,7 +164,7 @@ func InitTest(t *testing.T) (protocol.Protocol, *common.URL) { ...@@ -164,7 +164,7 @@ func InitTest(t *testing.T) (protocol.Protocol, *common.URL) {
type ( type (
User struct { User struct {
Id string `json:"id"` ID string `json:"id"`
Name string `json:"name"` Name string `json:"name"`
} }
...@@ -179,19 +179,19 @@ func (u *UserProvider) GetBigPkg(ctx context.Context, req []interface{}, rsp *Us ...@@ -179,19 +179,19 @@ func (u *UserProvider) GetBigPkg(ctx context.Context, req []interface{}, rsp *Us
// use chinese for test // use chinese for test
argBuf.WriteString("击鼓其镗,踊跃用兵。土国城漕,我独南行。从孙子仲,平陈与宋。不我以归,忧心有忡。爰居爰处?爰丧其马?于以求之?于林之下。死生契阔,与子成说。执子之手,与子偕老。于嗟阔兮,不我活兮。于嗟洵兮,不我信兮。") argBuf.WriteString("击鼓其镗,踊跃用兵。土国城漕,我独南行。从孙子仲,平陈与宋。不我以归,忧心有忡。爰居爰处?爰丧其马?于以求之?于林之下。死生契阔,与子成说。执子之手,与子偕老。于嗟阔兮,不我活兮。于嗟洵兮,不我信兮。")
} }
rsp.Id = argBuf.String() rsp.ID = argBuf.String()
rsp.Name = argBuf.String() rsp.Name = argBuf.String()
return nil return nil
} }
func (u *UserProvider) GetUser(ctx context.Context, req []interface{}, rsp *User) error { func (u *UserProvider) GetUser(ctx context.Context, req []interface{}, rsp *User) error {
rsp.Id = req[0].(string) rsp.ID = req[0].(string)
rsp.Name = req[1].(string) rsp.Name = req[1].(string)
return nil return nil
} }
func (u *UserProvider) GetUser0(id string, k *User, name string) (User, error) { func (u *UserProvider) GetUser0(id string, k *User, name string) (User, error) {
return User{Id: id, Name: name}, nil return User{ID: id, Name: name}, nil
} }
func (u *UserProvider) GetUser1() error { func (u *UserProvider) GetUser1() error {
...@@ -203,23 +203,23 @@ func (u *UserProvider) GetUser2() error { ...@@ -203,23 +203,23 @@ func (u *UserProvider) GetUser2() error {
} }
func (u *UserProvider) GetUser3(rsp *[]interface{}) error { func (u *UserProvider) GetUser3(rsp *[]interface{}) error {
*rsp = append(*rsp, User{Id: "1", Name: "username"}) *rsp = append(*rsp, User{ID: "1", Name: "username"})
return nil return nil
} }
func (u *UserProvider) GetUser4(ctx context.Context, req []interface{}) ([]interface{}, error) { func (u *UserProvider) GetUser4(ctx context.Context, req []interface{}) ([]interface{}, error) {
return []interface{}{User{Id: req[0].([]interface{})[0].(string), Name: req[0].([]interface{})[1].(string)}}, nil return []interface{}{User{ID: req[0].([]interface{})[0].(string), Name: req[0].([]interface{})[1].(string)}}, nil
} }
func (u *UserProvider) GetUser5(ctx context.Context, req []interface{}) (map[interface{}]interface{}, error) { func (u *UserProvider) GetUser5(ctx context.Context, req []interface{}) (map[interface{}]interface{}, error) {
return map[interface{}]interface{}{"key": User{Id: req[0].(map[interface{}]interface{})["id"].(string), Name: req[0].(map[interface{}]interface{})["name"].(string)}}, nil return map[interface{}]interface{}{"key": User{ID: req[0].(map[interface{}]interface{})["id"].(string), Name: req[0].(map[interface{}]interface{})["name"].(string)}}, nil
} }
func (u *UserProvider) GetUser6(id int64) (*User, error) { func (u *UserProvider) GetUser6(id int64) (*User, error) {
if id == 0 { if id == 0 {
return nil, nil return nil, nil
} }
return &User{Id: "1"}, nil return &User{ID: "1"}, nil
} }
func (u *UserProvider) Reference() string { func (u *UserProvider) Reference() string {
......
...@@ -199,7 +199,7 @@ func TestHessianCodec_ReadAttachments(t *testing.T) { ...@@ -199,7 +199,7 @@ func TestHessianCodec_ReadAttachments(t *testing.T) {
body := &DubboResponse{ body := &DubboResponse{
RspObj: &CaseB{A: "A", B: CaseA{A: "a", B: 1, C: Case{A: "c", B: 2}}}, RspObj: &CaseB{A: "A", B: CaseA{A: "a", B: 1, C: Case{A: "c", B: 2}}},
Exception: nil, Exception: nil,
Attachments: map[string]interface{}{DUBBO_VERSION_KEY: "2.6.4", "att": AttachTestObject{Id: 23, Name: "haha"}}, Attachments: map[string]interface{}{DUBBO_VERSION_KEY: "2.6.4", "att": AttachTestObject{ID: 23, Name: "haha"}},
} }
resp, err := doTestHessianEncodeHeader(t, PackageResponse, Response_OK, body) resp, err := doTestHessianEncodeHeader(t, PackageResponse, Response_OK, body)
assert.NoError(t, err) assert.NoError(t, err)
...@@ -217,14 +217,14 @@ func TestHessianCodec_ReadAttachments(t *testing.T) { ...@@ -217,14 +217,14 @@ func TestHessianCodec_ReadAttachments(t *testing.T) {
attrs, err := codecR2.ReadAttachments() attrs, err := codecR2.ReadAttachments()
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "2.6.4", attrs[DUBBO_VERSION_KEY]) assert.Equal(t, "2.6.4", attrs[DUBBO_VERSION_KEY])
assert.Equal(t, AttachTestObject{Id: 23, Name: "haha"}, *(attrs["att"].(*AttachTestObject))) assert.Equal(t, AttachTestObject{ID: 23, Name: "haha"}, *(attrs["att"].(*AttachTestObject)))
assert.NotEqual(t, AttachTestObject{Id: 24, Name: "nohaha"}, *(attrs["att"].(*AttachTestObject))) assert.NotEqual(t, AttachTestObject{ID: 24, Name: "nohaha"}, *(attrs["att"].(*AttachTestObject)))
t.Log(attrs) t.Log(attrs)
} }
type AttachTestObject struct { type AttachTestObject struct {
Id int32 ID int32
Name string `dubbo:"name"` Name string `dubbo:"name"`
} }
......
...@@ -39,7 +39,7 @@ import ( ...@@ -39,7 +39,7 @@ import (
type ( type (
User struct { User struct {
Id string `json:"id"` ID string `json:"id"`
Name string `json:"name"` Name string `json:"name"`
} }
...@@ -82,7 +82,7 @@ func TestHTTPClientCall(t *testing.T) { ...@@ -82,7 +82,7 @@ func TestHTTPClientCall(t *testing.T) {
reply := &User{} reply := &User{}
err = client.Call(ctx, url, req, reply) err = client.Call(ctx, url, req, reply)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "1", reply.Id) assert.Equal(t, "1", reply.ID)
assert.Equal(t, "username", reply.Name) assert.Equal(t, "username", reply.Name)
// call GetUser0 // call GetUser0
...@@ -95,7 +95,7 @@ func TestHTTPClientCall(t *testing.T) { ...@@ -95,7 +95,7 @@ func TestHTTPClientCall(t *testing.T) {
reply = &User{} reply = &User{}
err = client.Call(ctx, url, req, reply) err = client.Call(ctx, url, req, reply)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, "1", reply.Id) assert.Equal(t, "1", reply.ID)
assert.Equal(t, "username", reply.Name) assert.Equal(t, "username", reply.Name)
// call GetUser1 // call GetUser1
...@@ -120,7 +120,7 @@ func TestHTTPClientCall(t *testing.T) { ...@@ -120,7 +120,7 @@ func TestHTTPClientCall(t *testing.T) {
reply1 := []User{} reply1 := []User{}
err = client.Call(ctx, url, req, &reply1) err = client.Call(ctx, url, req, &reply1)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, User{Id: "1", Name: "username"}, reply1[0]) assert.Equal(t, User{ID: "1", Name: "username"}, reply1[0])
// call GetUser3 // call GetUser3
ctx = context.WithValue(context.Background(), constant.DUBBOGO_CTX_KEY, map[string]string{ ctx = context.WithValue(context.Background(), constant.DUBBOGO_CTX_KEY, map[string]string{
...@@ -132,7 +132,7 @@ func TestHTTPClientCall(t *testing.T) { ...@@ -132,7 +132,7 @@ func TestHTTPClientCall(t *testing.T) {
reply1 = []User{} reply1 = []User{}
err = client.Call(ctx, url, req, &reply1) err = client.Call(ctx, url, req, &reply1)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, User{Id: "1", Name: "username"}, reply1[0]) assert.Equal(t, User{ID: "1", Name: "username"}, reply1[0])
// call GetUser4 // call GetUser4
ctx = context.WithValue(context.Background(), constant.DUBBOGO_CTX_KEY, map[string]string{ ctx = context.WithValue(context.Background(), constant.DUBBOGO_CTX_KEY, map[string]string{
...@@ -144,7 +144,7 @@ func TestHTTPClientCall(t *testing.T) { ...@@ -144,7 +144,7 @@ func TestHTTPClientCall(t *testing.T) {
reply = &User{} reply = &User{}
err = client.Call(ctx, url, req, reply) err = client.Call(ctx, url, req, reply)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, &User{Id: "", Name: ""}, reply) assert.Equal(t, &User{ID: "", Name: ""}, reply)
ctx = context.WithValue(context.Background(), constant.DUBBOGO_CTX_KEY, map[string]string{ ctx = context.WithValue(context.Background(), constant.DUBBOGO_CTX_KEY, map[string]string{
"X-Proxy-ID": "dubbogo", "X-Proxy-ID": "dubbogo",
...@@ -159,20 +159,20 @@ func TestHTTPClientCall(t *testing.T) { ...@@ -159,20 +159,20 @@ func TestHTTPClientCall(t *testing.T) {
reply = &User{} reply = &User{}
err = client.Call(ctx, url, req, reply) err = client.Call(ctx, url, req, reply)
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, &User{Id: "1", Name: ""}, reply) assert.Equal(t, &User{ID: "1", Name: ""}, reply)
// destroy // destroy
proto.Destroy() proto.Destroy()
} }
func (u *UserProvider) GetUser(ctx context.Context, req []interface{}, rsp *User) error { func (u *UserProvider) GetUser(ctx context.Context, req []interface{}, rsp *User) error {
rsp.Id = req[0].(string) rsp.ID = req[0].(string)
rsp.Name = req[1].(string) rsp.Name = req[1].(string)
return nil return nil
} }
func (u *UserProvider) GetUser0(id string, k *User, name string) (User, error) { func (u *UserProvider) GetUser0(id string, k *User, name string) (User, error) {
return User{Id: id, Name: name}, nil return User{ID: id, Name: name}, nil
} }
func (u *UserProvider) GetUser1() error { func (u *UserProvider) GetUser1() error {
...@@ -180,19 +180,19 @@ func (u *UserProvider) GetUser1() error { ...@@ -180,19 +180,19 @@ func (u *UserProvider) GetUser1() error {
} }
func (u *UserProvider) GetUser2(ctx context.Context, req []interface{}, rsp *[]User) error { func (u *UserProvider) GetUser2(ctx context.Context, req []interface{}, rsp *[]User) error {
*rsp = append(*rsp, User{Id: req[0].(string), Name: req[1].(string)}) *rsp = append(*rsp, User{ID: req[0].(string), Name: req[1].(string)})
return nil return nil
} }
func (u *UserProvider) GetUser3(ctx context.Context, req []interface{}) ([]User, error) { func (u *UserProvider) GetUser3(ctx context.Context, req []interface{}) ([]User, error) {
return []User{{Id: req[0].(string), Name: req[1].(string)}}, nil return []User{{ID: req[0].(string), Name: req[1].(string)}}, nil
} }
func (u *UserProvider) GetUser4(id float64) (*User, error) { func (u *UserProvider) GetUser4(id float64) (*User, error) {
if id == 0 { if id == 0 {
return nil, nil return nil, nil
} }
return &User{Id: "1"}, nil return &User{ID: "1"}, nil
} }
func (u *UserProvider) Reference() string { func (u *UserProvider) Reference() string {
......
...@@ -51,7 +51,7 @@ func (ji *JsonrpcInvoker) Invoke(ctx context.Context, invocation protocol.Invoca ...@@ -51,7 +51,7 @@ func (ji *JsonrpcInvoker) Invoke(ctx context.Context, invocation protocol.Invoca
url := ji.GetUrl() url := ji.GetUrl()
req := ji.client.NewRequest(url, inv.MethodName(), inv.Arguments()) req := ji.client.NewRequest(url, inv.MethodName(), inv.Arguments())
ctxNew := context.WithValue(ctx, constant.DUBBOGO_CTX_KEY, map[string]string{ ctxNew := context.WithValue(ctx, constant.DUBBOGO_CTX_KEY, map[string]string{
"X-Proxy-Id": "dubbogo", "X-Proxy-ID": "dubbogo",
"X-Services": url.Path, "X-Services": url.Path,
"X-Method": inv.MethodName(), "X-Method": inv.MethodName(),
}) })
......
...@@ -63,7 +63,7 @@ func TestJsonrpcInvokerInvoke(t *testing.T) { ...@@ -63,7 +63,7 @@ func TestJsonrpcInvokerInvoke(t *testing.T) {
invocation.WithReply(user))) invocation.WithReply(user)))
assert.NoError(t, res.Error()) assert.NoError(t, res.Error())
assert.Equal(t, User{Id: "1", Name: "username"}, *res.Result().(*User)) assert.Equal(t, User{ID: "1", Name: "username"}, *res.Result().(*User))
// destroy // destroy
proto.Destroy() proto.Destroy()
......
...@@ -69,7 +69,7 @@ func (c *RestProviderConfig) UnmarshalYAML(unmarshal func(interface{}) error) er ...@@ -69,7 +69,7 @@ func (c *RestProviderConfig) UnmarshalYAML(unmarshal func(interface{}) error) er
// nolint // nolint
type RestServiceConfig struct { type RestServiceConfig struct {
InterfaceName string `required:"true" yaml:"interface" json:"interface,omitempty" property:"interface"` InterfaceName string `required:"true" yaml:"interface" json:"interface,omitempty" property:"interface"`
Url string `yaml:"url" json:"url,omitempty" property:"url"` URL string `yaml:"url" json:"url,omitempty" property:"url"`
Path string `yaml:"rest_path" json:"rest_path,omitempty" property:"rest_path"` Path string `yaml:"rest_path" json:"rest_path,omitempty" property:"rest_path"`
Produces string `yaml:"rest_produces" json:"rest_produces,omitempty" property:"rest_produces"` Produces string `yaml:"rest_produces" json:"rest_produces,omitempty" property:"rest_produces"`
Consumes string `yaml:"rest_consumes" json:"rest_consumes,omitempty" property:"rest_consumes"` Consumes string `yaml:"rest_consumes" json:"rest_consumes,omitempty" property:"rest_consumes"`
...@@ -96,7 +96,7 @@ func (c *RestServiceConfig) UnmarshalYAML(unmarshal func(interface{}) error) err ...@@ -96,7 +96,7 @@ func (c *RestServiceConfig) UnmarshalYAML(unmarshal func(interface{}) error) err
type RestMethodConfig struct { type RestMethodConfig struct {
InterfaceName string InterfaceName string
MethodName string `required:"true" yaml:"name" json:"name,omitempty" property:"name"` MethodName string `required:"true" yaml:"name" json:"name,omitempty" property:"name"`
Url string `yaml:"url" json:"url,omitempty" property:"url"` URL string `yaml:"url" json:"url,omitempty" property:"url"`
Path string `yaml:"rest_path" json:"rest_path,omitempty" property:"rest_path"` Path string `yaml:"rest_path" json:"rest_path,omitempty" property:"rest_path"`
Produces string `yaml:"rest_produces" json:"rest_produces,omitempty" property:"rest_produces"` Produces string `yaml:"rest_produces" json:"rest_produces,omitempty" property:"rest_produces"`
Consumes string `yaml:"rest_consumes" json:"rest_consumes,omitempty" property:"rest_consumes"` Consumes string `yaml:"rest_consumes" json:"rest_consumes,omitempty" property:"rest_consumes"`
......
...@@ -172,14 +172,14 @@ func TestRestInvokerInvoke(t *testing.T) { ...@@ -172,14 +172,14 @@ func TestRestInvokerInvoke(t *testing.T) {
invocation.WithArguments([]interface{}{1, int32(23), "username", "application/json"}), invocation.WithReply(user)) invocation.WithArguments([]interface{}{1, int32(23), "username", "application/json"}), invocation.WithReply(user))
res := invoker.Invoke(context.Background(), inv) res := invoker.Invoke(context.Background(), inv)
assert.NoError(t, res.Error()) assert.NoError(t, res.Error())
assert.Equal(t, User{Id: 1, Age: int32(23), Name: "username"}, *res.Result().(*User)) assert.Equal(t, User{ID: 1, Age: int32(23), Name: "username"}, *res.Result().(*User))
now := time.Now() now := time.Now()
inv = invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("GetUserOne"), inv = invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("GetUserOne"),
invocation.WithArguments([]interface{}{&User{1, &now, int32(23), "username"}}), invocation.WithReply(user)) invocation.WithArguments([]interface{}{&User{1, &now, int32(23), "username"}}), invocation.WithReply(user))
res = invoker.Invoke(context.Background(), inv) res = invoker.Invoke(context.Background(), inv)
assert.NoError(t, res.Error()) assert.NoError(t, res.Error())
assert.NotNil(t, res.Result()) assert.NotNil(t, res.Result())
assert.Equal(t, 1, res.Result().(*User).Id) assert.Equal(t, 1, res.Result().(*User).ID)
assert.Equal(t, now.Unix(), res.Result().(*User).Time.Unix()) assert.Equal(t, now.Unix(), res.Result().(*User).Time.Unix())
assert.Equal(t, int32(23), res.Result().(*User).Age) assert.Equal(t, int32(23), res.Result().(*User).Age)
assert.Equal(t, "username", res.Result().(*User).Name) assert.Equal(t, "username", res.Result().(*User).Name)
......
...@@ -130,7 +130,7 @@ func (p *UserProvider) Reference() string { ...@@ -130,7 +130,7 @@ func (p *UserProvider) Reference() string {
func (p *UserProvider) GetUser(ctx context.Context, id int, age int32, name string, contentType string) (*User, error) { func (p *UserProvider) GetUser(ctx context.Context, id int, age int32, name string, contentType string) (*User, error) {
return &User{ return &User{
Id: id, ID: id,
Time: nil, Time: nil,
Age: age, Age: age,
Name: name, Name: name,
...@@ -168,7 +168,7 @@ func (p *UserProvider) GetUserFive(ctx context.Context, user []interface{}) (*Us ...@@ -168,7 +168,7 @@ func (p *UserProvider) GetUserFive(ctx context.Context, user []interface{}) (*Us
} }
type User struct { type User struct {
Id int ID int
Time *time.Time Time *time.Time
Age int32 Age int32
Name string Name 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