diff --git a/config/config_loader.go b/config/config_loader.go index bb1069ce63f564c2268c7b81076c72b6d15f1b2d..cddccf48745f117cf7b60a70d001f2b3062056fc 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -340,7 +340,7 @@ func createInstance(url *common.URL) (registry.ServiceInstance, error) { ServiceName: appConfig.Name, Host: host, Port: int(port), - Id: host + constant.KEY_SEPARATOR + url.Port, + ID: host + constant.KEY_SEPARATOR + url.Port, Enable: true, Healthy: true, Metadata: metadata, diff --git a/config/reference_config.go b/config/reference_config.go index a97018acc7b6db98d63966092bb10a230129f342..a2a163441a886ad3368d72d1fda2ee27537573a6 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -46,7 +46,7 @@ type ReferenceConfig struct { id string InterfaceName string `required:"true" yaml:"interface" json:"interface,omitempty" property:"interface"` 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"` Protocol string `default:"dubbo" yaml:"protocol" json:"protocol,omitempty" property:"protocol"` Registry string `yaml:"registry" json:"registry,omitempty" property:"registry"` @@ -94,40 +94,40 @@ func (c *ReferenceConfig) Refer(_ interface{}) { cfgURL := common.NewURLWithOptions( common.WithPath(c.InterfaceName), common.WithProtocol(c.Protocol), - common.WithParams(c.getUrlMap()), + common.WithParams(c.getURLMap()), common.WithParamsValue(constant.BEAN_NAME_KEY, c.id), ) if c.ForceTag { cfgURL.AddParam(constant.ForceUseTag, "true") } c.postProcessConfig(cfgURL) - if c.Url != "" { + if c.URL != "" { // 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 { - serviceUrl, err := common.NewURL(urlStr) + serviceURL, err := common.NewURL(urlStr) if err != nil { panic(fmt.Sprintf("user specified URL %v refer error, error message is %v ", urlStr, err.Error())) } - if serviceUrl.Protocol == constant.REGISTRY_PROTOCOL { - serviceUrl.SubURL = cfgURL - c.urls = append(c.urls, serviceUrl) + if serviceURL.Protocol == constant.REGISTRY_PROTOCOL { + serviceURL.SubURL = cfgURL + c.urls = append(c.urls, serviceURL) } else { - if serviceUrl.Path == "" { - serviceUrl.Path = "/" + c.InterfaceName + if serviceURL.Path == "" { + serviceURL.Path = "/" + c.InterfaceName } // merge url need to do - newUrl := common.MergeUrl(serviceUrl, cfgURL) - c.urls = append(c.urls, newUrl) + newURL := common.MergeURL(serviceURL, cfgURL) + c.urls = append(c.urls, newURL) } } } else { // 2. assemble SubURL from register center's configuration mode c.urls = loadRegistries(c.Registry, consumerConfig.Registries, common.CONSUMER) - // set url to regUrls - for _, regUrl := range c.urls { - regUrl.SubURL = cfgURL + // set url to regURLs + for _, regURL := range c.urls { + regURL.SubURL = cfgURL } } @@ -135,24 +135,24 @@ func (c *ReferenceConfig) Refer(_ interface{}) { c.invoker = extension.GetProtocol(c.urls[0].Protocol).Refer(c.urls[0]) } else { invokers := make([]protocol.Invoker, 0, len(c.urls)) - var regUrl *common.URL + var regURL *common.URL for _, u := range c.urls { invokers = append(invokers, extension.GetProtocol(u.Protocol).Refer(u)) if u.Protocol == constant.REGISTRY_PROTOCOL { - regUrl = u + regURL = u } } // TODO(decouple from directory, config should not depend on directory module) var hitClu string - if regUrl != nil { + if regURL != nil { // for multi-subscription scenario, use 'zone-aware' policy by default hitClu = constant.ZONEAWARE_CLUSTER_NAME } else { // not a registry url, must be direct invoke. hitClu = constant.FAILOVER_CLUSTER_NAME if len(invokers) > 0 { - u := invokers[0].GetUrl() + u := invokers[0].GetURL() if nil != &u { hitClu = u.GetParam(constant.CLUSTER_KEY, constant.ZONEAWARE_CLUSTER_NAME) } @@ -192,7 +192,7 @@ func (c *ReferenceConfig) GetProxy() *proxy.Proxy { return c.pxy } -func (c *ReferenceConfig) getUrlMap() url.Values { +func (c *ReferenceConfig) getURLMap() url.Values { urlMap := url.Values{} // first set user params for k, v := range c.Params { diff --git a/config/reference_config_test.go b/config/reference_config_test.go index f47bb4bd84efa61e6d8a5b7d36f8fa1225080b79..433d584c92f00e653e02c9d741410fa27ba291cf 100644 --- a/config/reference_config_test.go +++ b/config/reference_config_test.go @@ -235,7 +235,7 @@ func TestReferP2P(t *testing.T) { doInitConsumer() extension.SetProtocol("dubbo", GetProtocol) 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 { reference.Refer(nil) @@ -249,7 +249,7 @@ func TestReferMultiP2P(t *testing.T) { doInitConsumer() extension.SetProtocol("dubbo", GetProtocol) 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 { reference.Refer(nil) @@ -264,7 +264,7 @@ func TestReferMultiP2PWithReg(t *testing.T) { extension.SetProtocol("dubbo", GetProtocol) extension.SetProtocol("registry", GetProtocol) 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 { reference.Refer(nil) @@ -292,11 +292,11 @@ func TestForking(t *testing.T) { extension.SetProtocol("dubbo", GetProtocol) extension.SetProtocol("registry", GetProtocol) 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 { 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.NotNil(t, reference.pxy) assert.NotNil(t, reference.Cluster) @@ -309,16 +309,16 @@ func TestSticky(t *testing.T) { extension.SetProtocol("dubbo", GetProtocol) extension.SetProtocol("registry", GetProtocol) 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.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) - 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) - 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) } @@ -340,13 +340,13 @@ func (*mockRegistryProtocol) Refer(url *common.URL) protocol.Invoker { } func (*mockRegistryProtocol) Export(invoker protocol.Invoker) protocol.Exporter { - registryUrl := getRegistryUrl(invoker) - if registryUrl.Protocol == "service-discovery" { + registryURL := getRegistryURL(invoker) + if registryURL.Protocol == "service-discovery" { metaDataService, err := extension.GetMetadataService(GetApplicationConfig().MetadataType) if err != nil { panic(err) } - ok, err := metaDataService.ExportURL(invoker.GetUrl().SubURL.Clone()) + ok, err := metaDataService.ExportURL(invoker.GetURL().SubURL.Clone()) if err != nil { panic(err) } @@ -361,9 +361,9 @@ func (*mockRegistryProtocol) Destroy() { // 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 - url := invoker.GetUrl() + url := invoker.GetURL() // if the protocol == registry ,set protocol the registry value in url.params if url.Protocol == constant.REGISTRY_PROTOCOL { protocol := url.GetParam(constant.REGISTRY_KEY, "") diff --git a/config_center/nacos/impl.go b/config_center/nacos/impl.go index 8e56d232732b57e6e00f53f881f6344c48901ab6..d35e87e717fb08676e9ada95be5ec1d86dca577a 100644 --- a/config_center/nacos/impl.go +++ b/config_center/nacos/impl.go @@ -182,8 +182,8 @@ func (n *nacosDynamicConfiguration) GetDone() chan struct{} { return n.done } -// GetUrl Get Url -func (n *nacosDynamicConfiguration) GetUrl() *common.URL { +// GetURL Get URL +func (n *nacosDynamicConfiguration) GetURL() *common.URL { return n.url } diff --git a/filter/filter_impl/auth/default_authenticator_test.go b/filter/filter_impl/auth/default_authenticator_test.go index c253caf157bbeda38e5627762b0e59ea8cb17022..55339455057d761f2c9377d0e4807de0c6b82fb3 100644 --- a/filter/filter_impl/auth/default_authenticator_test.go +++ b/filter/filter_impl/auth/default_authenticator_test.go @@ -44,7 +44,7 @@ func TestDefaultAuthenticator_Authenticate(t *testing.T) { testurl.SetParam(constant.SECRET_ACCESS_KEY_KEY, secret) parmas := []interface{}{"OK", struct { Name string - Id int64 + ID int64 }{"YUYU", 1}} inv := invocation.NewRPCInvocation("test", parmas, nil) requestTime := strconv.Itoa(int(time.Now().Unix() * 1000)) diff --git a/filter/filter_impl/auth/provider_auth_test.go b/filter/filter_impl/auth/provider_auth_test.go index 9e68b645f73bb11930fd5c66725b84347b772b35..e416abc6e400cdf1a96753fcc0f9a0c37840d6b7 100644 --- a/filter/filter_impl/auth/provider_auth_test.go +++ b/filter/filter_impl/auth/provider_auth_test.go @@ -47,7 +47,7 @@ func TestProviderAuthFilter_Invoke(t *testing.T) { "OK", struct { Name string - Id int64 + ID int64 }{"YUYU", 1}, } inv := invocation.NewRPCInvocation("test", parmas, nil) diff --git a/filter/filter_impl/auth/sign_util_test.go b/filter/filter_impl/auth/sign_util_test.go index 69203e6f3be4c1a073d0453008ebd9c0090c5853..57f99b2699b7d2540a32e5367dc06faf83d7a884 100644 --- a/filter/filter_impl/auth/sign_util_test.go +++ b/filter/filter_impl/auth/sign_util_test.go @@ -64,7 +64,7 @@ func TestSignWithParams(t *testing.T) { params := []interface{}{ "a", 1, struct { Name string - Id int64 + ID int64 }{"YuYu", 1}, } signature, _ := SignWithParams(params, metadata, key) @@ -84,13 +84,13 @@ func Test_toBytes(t *testing.T) { params := []interface{}{ "a", 1, struct { Name string - Id int64 + ID int64 }{"YuYu", 1}, } params2 := []interface{}{ "a", 1, struct { Name string - Id int64 + ID int64 }{"YuYu", 1}, } jsonBytes, _ := toBytes(params) diff --git a/metadata/definition/definition.go b/metadata/definition/definition.go index a0323137b70ff6ea34249b10e82d4f5cd84c9cb0..e387dee192a29393c938bf6ba7706b89536bb3bb 100644 --- a/metadata/definition/definition.go +++ b/metadata/definition/definition.go @@ -57,13 +57,13 @@ func (def *ServiceDefinition) String() string { } var param strings.Builder 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())) } var types strings.Builder 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()) } @@ -84,7 +84,7 @@ type MethodDefinition struct { // TypeDefinition is the describer of type definition type TypeDefinition struct { - Id string + ID string Type string Items []TypeDefinition Enums []string diff --git a/metadata/definition/mock.go b/metadata/definition/mock.go index 02f969c6c6c4719d3ad19e6009da66ff3397d870..65cef4ef510a611ad59a80fd2b7516316cf15fe3 100644 --- a/metadata/definition/mock.go +++ b/metadata/definition/mock.go @@ -23,7 +23,7 @@ import ( ) type User struct { - Id string + ID string Name string Age int32 Time time.Time diff --git a/metadata/service/inmemory/metadata_service_proxy_factory_test.go b/metadata/service/inmemory/metadata_service_proxy_factory_test.go index 5f62035328cf99fef9fcc0882803998401b25e74..75c66778846ad741097e347989a54fe80665c8a3 100644 --- a/metadata/service/inmemory/metadata_service_proxy_factory_test.go +++ b/metadata/service/inmemory/metadata_service_proxy_factory_test.go @@ -47,7 +47,7 @@ func TestCreateProxy(t *testing.T) { return &mockProtocol{} }) ins := ®istry.DefaultServiceInstance{ - Id: "test-id", + ID: "test-id", ServiceName: "com.dubbo", Host: "localhost", Port: 8080, diff --git a/metadata/service/inmemory/service_proxy_test.go b/metadata/service/inmemory/service_proxy_test.go index c697faf04ca5fb0da33af6d7f025faf89c084256..523d55ae65b00449c65db76253ae4f9f0aee9c29 100644 --- a/metadata/service/inmemory/service_proxy_test.go +++ b/metadata/service/inmemory/service_proxy_test.go @@ -81,7 +81,7 @@ func createPxy() service.MetadataService { }) ins := ®istry.DefaultServiceInstance{ - Id: "test-id", + ID: "test-id", ServiceName: "com.dubbo", Host: "localhost", Port: 8080, diff --git a/metadata/service/remote/service_proxy_test.go b/metadata/service/remote/service_proxy_test.go index 6edbab5cb66c74736772efe6189005c8208807e0..39cc46a6bcf1a7d7f9f3a98b8329873e0148eeac 100644 --- a/metadata/service/remote/service_proxy_test.go +++ b/metadata/service/remote/service_proxy_test.go @@ -83,7 +83,7 @@ func createProxy() service.MetadataService { prepareTest() ins := ®istry.DefaultServiceInstance{ - Id: "test-id", + ID: "test-id", ServiceName: "com.dubbo", Host: "localhost", Port: 8080, @@ -110,34 +110,34 @@ func (m *mockMetadataReportFactory) CreateMetadataReport(*common.URL) report.Met type mockMetadataReport struct{} -func (m mockMetadataReport) StoreProviderMetadata(*identifier.MetadataIdentifier, string) error { +func (m mockMetadataReport) StoreProviderMetadata(*identifier.MetadataIDentifier, string) error { panic("implement me") } -func (m mockMetadataReport) StoreConsumerMetadata(*identifier.MetadataIdentifier, string) error { +func (m mockMetadataReport) StoreConsumerMetadata(*identifier.MetadataIDentifier, string) error { panic("implement me") } -func (m mockMetadataReport) SaveServiceMetadata(*identifier.ServiceMetadataIdentifier, *common.URL) error { +func (m mockMetadataReport) SaveServiceMetadata(*identifier.ServiceMetadataIDentifier, *common.URL) error { return nil } -func (m mockMetadataReport) RemoveServiceMetadata(*identifier.ServiceMetadataIdentifier) error { +func (m mockMetadataReport) RemoveServiceMetadata(*identifier.ServiceMetadataIDentifier) error { 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 } -func (m mockMetadataReport) SaveSubscribedData(*identifier.SubscriberMetadataIdentifier, string) error { +func (m mockMetadataReport) SaveSubscribedData(*identifier.SubscriberMetadataIDentifier, string) error { return nil } -func (m mockMetadataReport) GetSubscribedURLs(*identifier.SubscriberMetadataIdentifier) ([]string, error) { +func (m mockMetadataReport) GetSubscribedURLs(*identifier.SubscriberMetadataIDentifier) ([]string, error) { panic("implement me") } -func (m mockMetadataReport) GetServiceDefinition(*identifier.MetadataIdentifier) (string, error) { +func (m mockMetadataReport) GetServiceDefinition(*identifier.MetadataIDentifier) (string, error) { return "definition", nil } diff --git a/protocol/dubbo/dubbo_invoker_test.go b/protocol/dubbo/dubbo_invoker_test.go index cfa81ca0b380c0509a3a1464296ac743581807e6..a80fa4d009523ce578af7a34d370a7b87bc8ec21 100644 --- a/protocol/dubbo/dubbo_invoker_test.go +++ b/protocol/dubbo/dubbo_invoker_test.go @@ -56,7 +56,7 @@ func TestDubboInvokerInvoke(t *testing.T) { // Call res := invoker.Invoke(context.Background(), inv) 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 inv.SetAttachments(constant.ASYNC_KEY, "true") @@ -69,7 +69,7 @@ func TestDubboInvokerInvoke(t *testing.T) { inv.SetCallBack(func(response common.CallbackResponse) { r := response.(remoting.AsyncCallbackResponse) 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)) lock.Unlock() }) @@ -164,7 +164,7 @@ func InitTest(t *testing.T) (protocol.Protocol, *common.URL) { type ( User struct { - Id string `json:"id"` + ID string `json:"id"` Name string `json:"name"` } @@ -179,19 +179,19 @@ func (u *UserProvider) GetBigPkg(ctx context.Context, req []interface{}, rsp *Us // use chinese for test argBuf.WriteString("鍑婚紦鍏堕晽锛岃笂璺冪敤鍏点€傚湡鍥藉煄婕曪紝鎴戠嫭鍗楄銆備粠瀛欏瓙浠诧紝骞抽檲涓庡畫銆備笉鎴戜互褰掞紝蹇у績鏈夊俊銆傜埌灞呯埌澶勶紵鐖颁抚鍏堕┈锛熶簬浠ユ眰涔嬶紵浜庢灄涔嬩笅銆傛鐢熷闃旓紝涓庡瓙鎴愯銆傛墽瀛愪箣鎵嬶紝涓庡瓙鍋曡€併€備簬鍡熼様鍏紝涓嶆垜娲诲叜銆備簬鍡熸吹鍏紝涓嶆垜淇″叜銆�") } - rsp.Id = argBuf.String() + rsp.ID = argBuf.String() rsp.Name = argBuf.String() return nil } 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) return nil } 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 { @@ -203,23 +203,23 @@ func (u *UserProvider) GetUser2() 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 } 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) { - 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) { if id == 0 { return nil, nil } - return &User{Id: "1"}, nil + return &User{ID: "1"}, nil } func (u *UserProvider) Reference() string { diff --git a/protocol/dubbo/hessian2/hessian_dubbo_test.go b/protocol/dubbo/hessian2/hessian_dubbo_test.go index e603b0086bacaa27a8ae507e56e3ee8d3d7df9cc..e7f24584eddd2ee881db1bd3ebc7c4d21f9d2268 100644 --- a/protocol/dubbo/hessian2/hessian_dubbo_test.go +++ b/protocol/dubbo/hessian2/hessian_dubbo_test.go @@ -199,7 +199,7 @@ func TestHessianCodec_ReadAttachments(t *testing.T) { body := &DubboResponse{ RspObj: &CaseB{A: "A", B: CaseA{A: "a", B: 1, C: Case{A: "c", B: 2}}}, 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) assert.NoError(t, err) @@ -217,14 +217,14 @@ func TestHessianCodec_ReadAttachments(t *testing.T) { attrs, err := codecR2.ReadAttachments() assert.NoError(t, err) assert.Equal(t, "2.6.4", attrs[DUBBO_VERSION_KEY]) - assert.Equal(t, AttachTestObject{Id: 23, Name: "haha"}, *(attrs["att"].(*AttachTestObject))) - assert.NotEqual(t, AttachTestObject{Id: 24, Name: "nohaha"}, *(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))) t.Log(attrs) } type AttachTestObject struct { - Id int32 + ID int32 Name string `dubbo:"name"` } diff --git a/protocol/jsonrpc/http_test.go b/protocol/jsonrpc/http_test.go index caf0d222d21817cda4662882206dc6f3253ae1cc..4b5d125a2a895e52e57117b5fc83ec19af27db5e 100644 --- a/protocol/jsonrpc/http_test.go +++ b/protocol/jsonrpc/http_test.go @@ -39,7 +39,7 @@ import ( type ( User struct { - Id string `json:"id"` + ID string `json:"id"` Name string `json:"name"` } @@ -82,7 +82,7 @@ func TestHTTPClientCall(t *testing.T) { reply := &User{} err = client.Call(ctx, url, req, reply) assert.NoError(t, err) - assert.Equal(t, "1", reply.Id) + assert.Equal(t, "1", reply.ID) assert.Equal(t, "username", reply.Name) // call GetUser0 @@ -95,7 +95,7 @@ func TestHTTPClientCall(t *testing.T) { reply = &User{} err = client.Call(ctx, url, req, reply) assert.NoError(t, err) - assert.Equal(t, "1", reply.Id) + assert.Equal(t, "1", reply.ID) assert.Equal(t, "username", reply.Name) // call GetUser1 @@ -120,7 +120,7 @@ func TestHTTPClientCall(t *testing.T) { reply1 := []User{} err = client.Call(ctx, url, req, &reply1) 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 ctx = context.WithValue(context.Background(), constant.DUBBOGO_CTX_KEY, map[string]string{ @@ -132,7 +132,7 @@ func TestHTTPClientCall(t *testing.T) { reply1 = []User{} err = client.Call(ctx, url, req, &reply1) 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 ctx = context.WithValue(context.Background(), constant.DUBBOGO_CTX_KEY, map[string]string{ @@ -144,7 +144,7 @@ func TestHTTPClientCall(t *testing.T) { reply = &User{} err = client.Call(ctx, url, req, reply) 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{ "X-Proxy-ID": "dubbogo", @@ -159,20 +159,20 @@ func TestHTTPClientCall(t *testing.T) { reply = &User{} err = client.Call(ctx, url, req, reply) assert.NoError(t, err) - assert.Equal(t, &User{Id: "1", Name: ""}, reply) + assert.Equal(t, &User{ID: "1", Name: ""}, reply) // destroy proto.Destroy() } 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) return nil } 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 { @@ -180,19 +180,19 @@ func (u *UserProvider) GetUser1() 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 } 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) { if id == 0 { return nil, nil } - return &User{Id: "1"}, nil + return &User{ID: "1"}, nil } func (u *UserProvider) Reference() string { diff --git a/protocol/jsonrpc/jsonrpc_invoker.go b/protocol/jsonrpc/jsonrpc_invoker.go index 357443f5d4efbe5159fb6c0e09d3dab51266dc73..f194d6dc2177def1fdbdec4eb763b59b1fd27412 100644 --- a/protocol/jsonrpc/jsonrpc_invoker.go +++ b/protocol/jsonrpc/jsonrpc_invoker.go @@ -51,7 +51,7 @@ func (ji *JsonrpcInvoker) Invoke(ctx context.Context, invocation protocol.Invoca url := ji.GetUrl() req := ji.client.NewRequest(url, inv.MethodName(), inv.Arguments()) ctxNew := context.WithValue(ctx, constant.DUBBOGO_CTX_KEY, map[string]string{ - "X-Proxy-Id": "dubbogo", + "X-Proxy-ID": "dubbogo", "X-Services": url.Path, "X-Method": inv.MethodName(), }) diff --git a/protocol/jsonrpc/jsonrpc_invoker_test.go b/protocol/jsonrpc/jsonrpc_invoker_test.go index c6049291fcb77d99430e4f1ab8f018f52970da42..e5f242e50701e9e7d7e26c7dd83300e7869fe69e 100644 --- a/protocol/jsonrpc/jsonrpc_invoker_test.go +++ b/protocol/jsonrpc/jsonrpc_invoker_test.go @@ -63,7 +63,7 @@ func TestJsonrpcInvokerInvoke(t *testing.T) { invocation.WithReply(user))) 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 proto.Destroy() diff --git a/protocol/rest/config/rest_config.go b/protocol/rest/config/rest_config.go index 27c67db12d1477470550a2f75779b25113781a04..70a990344b35122e78b98e312f7b8f37cb699313 100644 --- a/protocol/rest/config/rest_config.go +++ b/protocol/rest/config/rest_config.go @@ -69,7 +69,7 @@ func (c *RestProviderConfig) UnmarshalYAML(unmarshal func(interface{}) error) er // nolint type RestServiceConfig struct { 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"` Produces string `yaml:"rest_produces" json:"rest_produces,omitempty" property:"rest_produces"` 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 type RestMethodConfig struct { InterfaceName string 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"` Produces string `yaml:"rest_produces" json:"rest_produces,omitempty" property:"rest_produces"` Consumes string `yaml:"rest_consumes" json:"rest_consumes,omitempty" property:"rest_consumes"` diff --git a/protocol/rest/rest_invoker_test.go b/protocol/rest/rest_invoker_test.go index 5a5bd2cc2ac98b96c593934d58a975b23aacfe52..4630d8e262e69c56bb41eca4f5c1b419de0cc4fe 100644 --- a/protocol/rest/rest_invoker_test.go +++ b/protocol/rest/rest_invoker_test.go @@ -172,14 +172,14 @@ func TestRestInvokerInvoke(t *testing.T) { invocation.WithArguments([]interface{}{1, int32(23), "username", "application/json"}), invocation.WithReply(user)) res := invoker.Invoke(context.Background(), inv) 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() inv = invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("GetUserOne"), invocation.WithArguments([]interface{}{&User{1, &now, int32(23), "username"}}), invocation.WithReply(user)) res = invoker.Invoke(context.Background(), inv) assert.NoError(t, res.Error()) 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, int32(23), res.Result().(*User).Age) assert.Equal(t, "username", res.Result().(*User).Name) diff --git a/protocol/rest/rest_protocol_test.go b/protocol/rest/rest_protocol_test.go index 48095648466a018fbf07bd49f1b653d776385bf8..f765a5daf6130c32bffa24cf9516c90b5d8a55ab 100644 --- a/protocol/rest/rest_protocol_test.go +++ b/protocol/rest/rest_protocol_test.go @@ -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) { return &User{ - Id: id, + ID: id, Time: nil, Age: age, Name: name, @@ -168,7 +168,7 @@ func (p *UserProvider) GetUserFive(ctx context.Context, user []interface{}) (*Us } type User struct { - Id int + ID int Time *time.Time Age int32 Name string diff --git a/registry/consul/service_discovery.go b/registry/consul/service_discovery.go index da5d8d075b5b2740139162f2bcffeabeaca02ab0..6eba07d6c45f16eacba1ab0d94aea648cd47e9ea 100644 --- a/registry/consul/service_discovery.go +++ b/registry/consul/service_discovery.go @@ -216,12 +216,12 @@ func (csd *consulServiceDiscovery) Unregister(instance registry.ServiceInstance) } err = consulClient.Agent().ServiceDeregister(buildID(instance)) if err != nil { - logger.Errorf("unregister service instance %s,error: %v", instance.GetId(), err) + logger.Errorf("unregister service instance %s,error: %v", instance.GetID(), err) return err } stopChanel, ok := csd.ttl.Load(buildID(instance)) if !ok { - logger.Warnf("ttl for service instance %s didn't exist", instance.GetId()) + logger.Warnf("ttl for service instance %s didn't exist", instance.GetID()) return nil } close(stopChanel.(chan struct{})) @@ -317,7 +317,7 @@ func (csd *consulServiceDiscovery) GetInstances(serviceName string) []registry.S healthy = true } res = append(res, ®istry.DefaultServiceInstance{ - Id: ins.Service.ID, + ID: ins.Service.ID, ServiceName: ins.Service.Service, Host: ins.Service.Address, Port: ins.Service.Port, @@ -399,7 +399,7 @@ func (csd *consulServiceDiscovery) AddListener(listener *registry.ServiceInstanc healthy = true } instances = append(instances, ®istry.DefaultServiceInstance{ - Id: ins.Service.ID, + ID: ins.Service.ID, ServiceName: ins.Service.Service, Host: ins.Service.Address, Port: ins.Service.Port, @@ -484,6 +484,6 @@ func getDeregisterAfter(metadata map[string]string) string { // nolint func buildID(instance registry.ServiceInstance) string { - id := fmt.Sprintf("id:%s,serviceName:%s,host:%s,port:%d", instance.GetId(), instance.GetServiceName(), instance.GetHost(), instance.GetPort()) + id := fmt.Sprintf("id:%s,serviceName:%s,host:%s,port:%d", instance.GetID(), instance.GetServiceName(), instance.GetHost(), instance.GetPort()) return id } diff --git a/registry/consul/service_discovery_test.go b/registry/consul/service_discovery_test.go index 68e804294d7677657311b0f6a3ab7b42721688a8..e68223d4451aa564b50feee456a270770057415c 100644 --- a/registry/consul/service_discovery_test.go +++ b/registry/consul/service_discovery_test.go @@ -121,7 +121,7 @@ func TestConsulServiceDiscovery_CRUD(t *testing.T) { instanceResult := page.GetData()[0].(*registry.DefaultServiceInstance) assert.NotNil(t, instanceResult) - assert.Equal(t, buildID(instance), instanceResult.GetId()) + assert.Equal(t, buildID(instance), instanceResult.GetID()) assert.Equal(t, instance.GetHost(), instanceResult.GetHost()) assert.Equal(t, instance.GetPort(), instanceResult.GetPort()) assert.Equal(t, instance.GetServiceName(), instanceResult.GetServiceName()) @@ -187,7 +187,7 @@ func prepareService() (registry.ServiceInstance, *common.URL) { "consul-watch-timeout=" + strconv.Itoa(consulWatchTimeout)) return ®istry.DefaultServiceInstance{ - Id: id, + ID: id, ServiceName: service, Host: registryHost, Port: registryPort, diff --git a/registry/event/event_publishing_service_deiscovery_test.go b/registry/event/event_publishing_service_deiscovery_test.go index 4979f1d8043675a5d98b710fad8a8eb2167831f4..2448188b9d938dece23d63deaf1cfe510f2d199f 100644 --- a/registry/event/event_publishing_service_deiscovery_test.go +++ b/registry/event/event_publishing_service_deiscovery_test.go @@ -65,7 +65,7 @@ func TestEventPublishingServiceDiscovery_DispatchEvent(t *testing.T) { extension.SetAndInitGlobalDispatcher("direct") err := dc.Destroy() assert.Nil(t, err) - si := ®istry.DefaultServiceInstance{Id: "testServiceInstance"} + si := ®istry.DefaultServiceInstance{ID: "testServiceInstance"} err = dc.Register(si) assert.Nil(t, err) } @@ -99,7 +99,7 @@ type TestServiceInstancePreRegisteredEventListener struct { func (tel *TestServiceInstancePreRegisteredEventListener) OnEvent(e observer.Event) error { e1, ok := e.(*ServiceInstancePreRegisteredEvent) assert.Equal(tel.T(), ok, true) - assert.Equal(tel.T(), "testServiceInstance", e1.getServiceInstance().GetId()) + assert.Equal(tel.T(), "testServiceInstance", e1.getServiceInstance().GetID()) return nil } diff --git a/registry/file/service_discovery_test.go b/registry/file/service_discovery_test.go index ee2ad272274f814f7a1989c39bad8725968b7282..e827399179d632a61022804ef1fea1436a1de2f4 100644 --- a/registry/file/service_discovery_test.go +++ b/registry/file/service_discovery_test.go @@ -58,7 +58,7 @@ func TestCURDFileSystemServiceDiscovery(t *testing.T) { serviceName := "service-name" + strconv.Itoa(rand.Intn(10000)) md["t1"] = "test1" r1 := ®istry.DefaultServiceInstance{ - Id: "123456789", + ID: "123456789", ServiceName: serviceName, Host: "127.0.0.1", Port: 2233, @@ -71,7 +71,7 @@ func TestCURDFileSystemServiceDiscovery(t *testing.T) { instances := serviceDiscovery.GetInstances(r1.ServiceName) assert.Equal(t, 1, len(instances)) - assert.Equal(t, r1.Id, instances[0].GetId()) + assert.Equal(t, r1.ID, instances[0].GetID()) assert.Equal(t, r1.ServiceName, instances[0].GetServiceName()) assert.Equal(t, r1.Port, instances[0].GetPort()) diff --git a/registry/nacos/service_discovery.go b/registry/nacos/service_discovery.go index 785e39579ed6f9d1842d43fdb99faaf00b00052a..f9e30d2a33e925ccc72ead50481edf98469f1926 100644 --- a/registry/nacos/service_discovery.go +++ b/registry/nacos/service_discovery.go @@ -153,7 +153,7 @@ func (n *nacosServiceDiscovery) GetInstances(serviceName string) []registry.Serv delete(metadata, idKey) res = append(res, ®istry.DefaultServiceInstance{ - Id: id, + ID: id, ServiceName: ins.ServiceName, Host: ins.Ip, Port: int(ins.Port), @@ -229,7 +229,7 @@ func (n *nacosServiceDiscovery) AddListener(listener *registry.ServiceInstancesC delete(metadata, idKey) instances = append(instances, ®istry.DefaultServiceInstance{ - Id: id, + ID: id, ServiceName: service.ServiceName, Host: service.Ip, Port: int(service.Port), @@ -270,7 +270,7 @@ func (n *nacosServiceDiscovery) toRegisterInstance(instance registry.ServiceInst if metadata == nil { metadata = make(map[string]string, 1) } - metadata[idKey] = instance.GetId() + metadata[idKey] = instance.GetID() return vo.RegisterInstanceParam{ ServiceName: instance.GetServiceName(), Ip: instance.GetHost(), diff --git a/registry/nacos/service_discovery_test.go b/registry/nacos/service_discovery_test.go index a9bc27bcfcf6883d031950c43cdef0b7cca027a2..98460b0e963152f3075ab2d21d20b694be0223a8 100644 --- a/registry/nacos/service_discovery_test.go +++ b/registry/nacos/service_discovery_test.go @@ -93,7 +93,7 @@ func TestNacosServiceDiscovery_CRUD(t *testing.T) { host := "host" port := 123 instance := ®istry.DefaultServiceInstance{ - Id: id, + ID: id, ServiceName: serviceName, Host: host, Port: port, @@ -108,7 +108,7 @@ func TestNacosServiceDiscovery_CRUD(t *testing.T) { // clean data for local test err = serviceDiscovery.Unregister(®istry.DefaultServiceInstance{ - Id: id, + ID: id, ServiceName: serviceName, Host: host, Port: port, @@ -129,7 +129,7 @@ func TestNacosServiceDiscovery_CRUD(t *testing.T) { instance = page.GetData()[0].(*registry.DefaultServiceInstance) assert.NotNil(t, instance) - assert.Equal(t, id, instance.GetId()) + assert.Equal(t, id, instance.GetID()) assert.Equal(t, host, instance.GetHost()) assert.Equal(t, port, instance.GetPort()) // TODO: console.nacos.io has updated to nacos 2.0 and serviceName has changed in 2.0, so ignore temporarily. diff --git a/registry/service_instance.go b/registry/service_instance.go index 43a1640eead7be1774556f25c9b8f97a75588801..6802cc0107e64f4441e600a0db4cdf5de1cec293 100644 --- a/registry/service_instance.go +++ b/registry/service_instance.go @@ -24,8 +24,8 @@ import ( // ServiceInstance is the model class of an instance of a service, which is used for service registration and discovery. type ServiceInstance interface { - // GetId will return this instance's id. It should be unique. - GetId() string + // GetID will return this instance's id. It should be unique. + GetID() string // GetServiceName will return the serviceName GetServiceName() string @@ -49,7 +49,7 @@ type ServiceInstance interface { // DefaultServiceInstance the default implementation of ServiceInstance // or change the ServiceInstance to be struct??? type DefaultServiceInstance struct { - Id string + ID string ServiceName string Host string Port int @@ -58,9 +58,9 @@ type DefaultServiceInstance struct { Metadata map[string]string } -// GetId will return this instance's id. It should be unique. -func (d *DefaultServiceInstance) GetId() string { - return d.Id +// GetID will return this instance's id. It should be unique. +func (d *DefaultServiceInstance) GetID() string { + return d.ID } // GetServiceName will return the serviceName diff --git a/registry/servicediscovery/instance/random/random_service_instance_selector_test.go b/registry/servicediscovery/instance/random/random_service_instance_selector_test.go index c53c058be912ba6fd2a66e42883914fdf1d60eb1..ae040627c013c7d53ed62b591ea14ef60e5aa254 100644 --- a/registry/servicediscovery/instance/random/random_service_instance_selector_test.go +++ b/registry/servicediscovery/instance/random/random_service_instance_selector_test.go @@ -34,7 +34,7 @@ func TestRandomServiceInstanceSelector_Select(t *testing.T) { selector := NewRandomServiceInstanceSelector() serviceInstances := []registry.ServiceInstance{ ®istry.DefaultServiceInstance{ - Id: "1", + ID: "1", ServiceName: "test1", Host: "127.0.0.1:80", Port: 0, @@ -43,7 +43,7 @@ func TestRandomServiceInstanceSelector_Select(t *testing.T) { Metadata: nil, }, ®istry.DefaultServiceInstance{ - Id: "2", + ID: "2", ServiceName: "test2", Host: "127.0.0.1:80", Port: 0, diff --git a/registry/servicediscovery/synthesizer/rest/rest_subscribed_urls_synthesizer_test.go b/registry/servicediscovery/synthesizer/rest/rest_subscribed_urls_synthesizer_test.go index 1bb38c92e32942fb1a39bbaeb9617013459bcdfe..93130d172921ac64662028cf8b10fde1e22e6d3e 100644 --- a/registry/servicediscovery/synthesizer/rest/rest_subscribed_urls_synthesizer_test.go +++ b/registry/servicediscovery/synthesizer/rest/rest_subscribed_urls_synthesizer_test.go @@ -37,7 +37,7 @@ func TestRestSubscribedURLsSynthesizer_Synthesize(t *testing.T) { subUrl, _ := common.NewURL("rest://127.0.0.1:20000/org.apache.dubbo-go.mockService") instances := []registry.ServiceInstance{ ®istry.DefaultServiceInstance{ - Id: "test1", + ID: "test1", ServiceName: "test1", Host: "127.0.0.1:80", Port: 80, @@ -46,7 +46,7 @@ func TestRestSubscribedURLsSynthesizer_Synthesize(t *testing.T) { Metadata: nil, }, ®istry.DefaultServiceInstance{ - Id: "test2", + ID: "test2", ServiceName: "test2", Host: "127.0.0.2:8081", Port: 8081, diff --git a/registry/zookeeper/service_discovery.go b/registry/zookeeper/service_discovery.go index 67c89a0d102fe314b9d3222baac9ea5339e88352..463016f7556d2f10261da29227637a18a88ba316 100644 --- a/registry/zookeeper/service_discovery.go +++ b/registry/zookeeper/service_discovery.go @@ -316,7 +316,7 @@ func (zksd *zookeeperServiceDiscovery) toCuratorInstance(instance registry.Servi pl["metadata"] = instance.GetMetadata() cuis := &curator_discovery.ServiceInstance{ Name: instance.GetServiceName(), - Id: id, + ID: id, Address: instance.GetHost(), Port: instance.GetPort(), Payload: pl, @@ -329,12 +329,12 @@ func (zksd *zookeeperServiceDiscovery) toCuratorInstance(instance registry.Servi func (zksd *zookeeperServiceDiscovery) toZookeeperInstance(cris *curator_discovery.ServiceInstance) registry.ServiceInstance { pl, ok := cris.Payload.(map[string]interface{}) if !ok { - logger.Errorf("[zkServiceDiscovery] toZookeeperInstance{%s} payload is not map[string]interface{}", cris.Id) + logger.Errorf("[zkServiceDiscovery] toZookeeperInstance{%s} payload is not map[string]interface{}", cris.ID) return nil } mdi, ok := pl["metadata"].(map[string]interface{}) if !ok { - logger.Errorf("[zkServiceDiscovery] toZookeeperInstance{%s} metadata is not map[string]interface{}", cris.Id) + logger.Errorf("[zkServiceDiscovery] toZookeeperInstance{%s} metadata is not map[string]interface{}", cris.ID) return nil } md := make(map[string]string, len(mdi)) @@ -342,7 +342,7 @@ func (zksd *zookeeperServiceDiscovery) toZookeeperInstance(cris *curator_discove md[k] = fmt.Sprint(v) } return ®istry.DefaultServiceInstance{ - Id: cris.Id, + ID: cris.ID, ServiceName: cris.Name, Host: cris.Address, Port: cris.Port, diff --git a/registry/zookeeper/service_discovery_test.go b/registry/zookeeper/service_discovery_test.go index a73ecc99652d0b234f07036f2cfe3c2bb2aad580..aa3d77046c55b5acd284e064087738aa7e0332ca 100644 --- a/registry/zookeeper/service_discovery_test.go +++ b/registry/zookeeper/service_discovery_test.go @@ -86,7 +86,7 @@ func TestCURDZookeeperServiceDiscovery(t *testing.T) { md := make(map[string]string) md["t1"] = "test1" err = sd.Register(®istry.DefaultServiceInstance{ - Id: "testId", + ID: "testID", ServiceName: testName, Host: "127.0.0.1", Port: 2233, @@ -100,12 +100,12 @@ func TestCURDZookeeperServiceDiscovery(t *testing.T) { assert.Equal(t, 1, testsPager.GetDataSize()) assert.Equal(t, 1, testsPager.GetTotalPages()) test := testsPager.GetData()[0].(registry.ServiceInstance) - assert.Equal(t, "127.0.0.1:2233", test.GetId()) + assert.Equal(t, "127.0.0.1:2233", test.GetID()) assert.Equal(t, "test1", test.GetMetadata()["t1"]) md["t1"] = "test12" err = sd.Update(®istry.DefaultServiceInstance{ - Id: "testId", + ID: "testID", ServiceName: testName, Host: "127.0.0.1", Port: 2233, @@ -131,7 +131,7 @@ func TestCURDZookeeperServiceDiscovery(t *testing.T) { assert.Equal(t, testName, names.Values()[0]) err = sd.Unregister(®istry.DefaultServiceInstance{ - Id: "testId", + ID: "testID", ServiceName: testName, Host: "127.0.0.1", Port: 2233, @@ -153,7 +153,7 @@ func TestAddListenerZookeeperServiceDiscovery(t *testing.T) { }() err = sd.Register(®istry.DefaultServiceInstance{ - Id: "testId", + ID: "testID", ServiceName: testName, Host: "127.0.0.1", Port: 2233, @@ -178,7 +178,7 @@ func TestAddListenerZookeeperServiceDiscovery(t *testing.T) { assert.NoError(t, err) err = sd.Update(®istry.DefaultServiceInstance{ - Id: "testId", + ID: "testID", ServiceName: testName, Host: "127.0.0.1", Port: 2233, @@ -198,6 +198,6 @@ type testNotify struct { func (tn *testNotify) Notify(e observer.Event) { ice := e.(*registry.ServiceInstancesChangedEvent) assert.Equal(tn.t, 1, len(ice.Instances)) - assert.Equal(tn.t, "127.0.0.1:2233", ice.Instances[0].GetId()) + assert.Equal(tn.t, "127.0.0.1:2233", ice.Instances[0].GetID()) tn.wg.Done() } diff --git a/remoting/exchange.go b/remoting/exchange.go index 07dc5496f7074dfbe3977557bfe044d82b4e0b53..06bcf523a0a4db885b1cd0f06c46de61cc83a073 100644 --- a/remoting/exchange.go +++ b/remoting/exchange.go @@ -45,9 +45,9 @@ func init() { sequence.Store(0) } -func SequenceId() int64 { +func SequenceID() int64 { // increse 2 for every request as the same before. - // We expect that the request from client to server, the requestId is even; but from server to client, the requestId is odd. + // We expect that the request from client to server, the requestID is even; but from server to client, the requestID is odd. return sequence.Add(2) } @@ -68,7 +68,7 @@ type Request struct { // The ID is auto increase. func NewRequest(version string) *Request { return &Request{ - ID: SequenceId(), + ID: SequenceID(), Version: version, } } @@ -142,7 +142,7 @@ type PendingResponse struct { } // NewPendingResponse aims to create PendingResponse. -// Id is always from ID of Request +// ID is always from ID of Request func NewPendingResponse(id int64) *PendingResponse { return &PendingResponse{ seq: id, diff --git a/remoting/exchange_server.go b/remoting/exchange_server.go index 41abe216c22d35a212d319120191e5202c5f5510..03cf58163a174b5a765155d935cf29252b246c01 100644 --- a/remoting/exchange_server.go +++ b/remoting/exchange_server.go @@ -32,14 +32,14 @@ type Server interface { // This is abstraction level. it is like facade. type ExchangeServer struct { Server Server - Url *common.URL + URL *common.URL } // Create ExchangeServer func NewExchangeServer(url *common.URL, server Server) *ExchangeServer { exchangServer := &ExchangeServer{ Server: server, - Url: url, + URL: url, } return exchangServer } diff --git a/remoting/getty/getty_client_test.go b/remoting/getty/getty_client_test.go index 3b59e9cdec1be4ea187d0da0a1458c6c3cbbf4ca..46d5b1ce7922de7e7fd0e0a81fb217b09eded948 100644 --- a/remoting/getty/getty_client_test.go +++ b/remoting/getty/getty_client_test.go @@ -122,7 +122,7 @@ func testGetBigPkg(t *testing.T, c *Client) { remoting.AddPendingResponse(pendingResponse) err := c.Request(request, 8*time.Second, pendingResponse) assert.NoError(t, err) - assert.NotEqual(t, "", user.Id) + assert.NotEqual(t, "", user.ID) assert.NotEqual(t, "", user.Name) } @@ -141,7 +141,7 @@ func testGetUser(t *testing.T, c *Client) { remoting.AddPendingResponse(pendingResponse) err := c.Request(request, 3*time.Second, pendingResponse) assert.NoError(t, err) - assert.Equal(t, User{Id: "1", Name: "username"}, *user) + assert.Equal(t, User{ID: "1", Name: "username"}, *user) } func testGetUser0(t *testing.T, c *Client) { @@ -164,7 +164,7 @@ func testGetUser0(t *testing.T, c *Client) { rsp.Reply = user err = c.Request(request, 3*time.Second, rsp) assert.NoError(t, err) - assert.Equal(t, User{Id: "1", Name: "username"}, *user) + assert.Equal(t, User{ID: "1", Name: "username"}, *user) } func testGetUser1(t *testing.T, c *Client) { @@ -219,7 +219,7 @@ func testGetUser3(t *testing.T, c *Client) { remoting.AddPendingResponse(pendingResponse) err = c.Request(request, 3*time.Second, pendingResponse) assert.NoError(t, err) - assert.Equal(t, &User{Id: "1", Name: "username"}, user2[0]) + assert.Equal(t, &User{ID: "1", Name: "username"}, user2[0]) } func testGetUser4(t *testing.T, c *Client) { @@ -237,7 +237,7 @@ func testGetUser4(t *testing.T, c *Client) { remoting.AddPendingResponse(pendingResponse) err = c.Request(request, 3*time.Second, pendingResponse) assert.NoError(t, err) - assert.Equal(t, &User{Id: "1", Name: "username"}, user2[0]) + assert.Equal(t, &User{ID: "1", Name: "username"}, user2[0]) } func testGetUser5(t *testing.T, c *Client) { @@ -256,7 +256,7 @@ func testGetUser5(t *testing.T, c *Client) { err = c.Request(request, 3*time.Second, pendingResponse) assert.NoError(t, err) assert.NotNil(t, user3) - assert.Equal(t, &User{Id: "1", Name: "username"}, user3["key"]) + assert.Equal(t, &User{ID: "1", Name: "username"}, user3["key"]) } func testGetUser6(t *testing.T, c *Client) { @@ -277,7 +277,7 @@ func testGetUser6(t *testing.T, c *Client) { remoting.AddPendingResponse(pendingResponse) err = c.Request(request, 3*time.Second, pendingResponse) assert.NoError(t, err) - assert.Equal(t, User{Id: "", Name: ""}, *user) + assert.Equal(t, User{ID: "", Name: ""}, *user) } func testGetUser61(t *testing.T, c *Client) { @@ -298,7 +298,7 @@ func testGetUser61(t *testing.T, c *Client) { remoting.AddPendingResponse(pendingResponse) err = c.Request(request, 3*time.Second, pendingResponse) assert.NoError(t, err) - assert.Equal(t, User{Id: "1", Name: ""}, *user) + assert.Equal(t, User{ID: "1", Name: ""}, *user) } func testClient_AsyncCall(t *testing.T, svr *Server, url *common.URL, client *Client) { @@ -319,7 +319,7 @@ func testClient_AsyncCall(t *testing.T, svr *Server, url *common.URL, client *Cl rsp.Callback = func(response common.CallbackResponse) { r := response.(remoting.AsyncCallbackResponse) rst := *r.Reply.(*remoting.Response).Result.(*protocol.RPCResult) - assert.Equal(t, User{Id: "4", Name: "username"}, *(rst.Rest.(*User))) + assert.Equal(t, User{ID: "4", Name: "username"}, *(rst.Rest.(*User))) lock.Unlock() } lock.Lock() @@ -417,7 +417,7 @@ func InitTest(t *testing.T) (*Server, *common.URL) { type ( User struct { - Id string `json:"id"` + ID string `json:"id"` Name string `json:"name"` } @@ -432,19 +432,19 @@ func (u *UserProvider) GetBigPkg(ctx context.Context, req []interface{}, rsp *Us argBuf.WriteString("鍑婚紦鍏堕晽锛岃笂璺冪敤鍏点€傚湡鍥藉煄婕曪紝鎴戠嫭鍗楄銆備粠瀛欏瓙浠诧紝骞抽檲涓庡畫銆備笉鎴戜互褰掞紝蹇у績鏈夊俊銆傜埌灞呯埌澶勶紵鐖颁抚鍏堕┈锛熶簬浠ユ眰涔嬶紵浜庢灄涔嬩笅銆傛鐢熷闃旓紝涓庡瓙鎴愯銆傛墽瀛愪箣鎵嬶紝涓庡瓙鍋曡€併€備簬鍡熼様鍏紝涓嶆垜娲诲叜銆備簬鍡熸吹鍏紝涓嶆垜淇″叜銆�") argBuf.WriteString("鍑婚紦鍏堕晽锛岃笂璺冪敤鍏点€傚湡鍥藉煄婕曪紝鎴戠嫭鍗楄銆備粠瀛欏瓙浠诧紝骞抽檲涓庡畫銆備笉鎴戜互褰掞紝蹇у績鏈夊俊銆傜埌灞呯埌澶勶紵鐖颁抚鍏堕┈锛熶簬浠ユ眰涔嬶紵浜庢灄涔嬩笅銆傛鐢熷闃旓紝涓庡瓙鎴愯銆傛墽瀛愪箣鎵嬶紝涓庡瓙鍋曡€併€備簬鍡熼様鍏紝涓嶆垜娲诲叜銆備簬鍡熸吹鍏紝涓嶆垜淇″叜銆�") } - rsp.Id = argBuf.String() + rsp.ID = argBuf.String() rsp.Name = argBuf.String() return nil } 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) return nil } 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 { @@ -456,23 +456,23 @@ func (u *UserProvider) GetUser2() 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 } 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) { - 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) { if id == 0 { return nil, nil } - return &User{Id: "1"}, nil + return &User{ID: "1"}, nil } func (u *UserProvider) Reference() string { diff --git a/remoting/getty/readwriter_test.go b/remoting/getty/readwriter_test.go index db6dd8e9f2e58979f65d6925bedc808d7a74cd79..9fa3a3281e585dab9ddf68bc6b848dd853ae7df6 100644 --- a/remoting/getty/readwriter_test.go +++ b/remoting/getty/readwriter_test.go @@ -163,7 +163,7 @@ func getServer(t *testing.T) (*Server, *common.URL) { type AdminProvider struct{} func (a *AdminProvider) GetAdmin(ctx context.Context, req []interface{}, rsp *User) error { - rsp.Id = req[0].(string) + rsp.ID = req[0].(string) rsp.Name = req[1].(string) return nil } diff --git a/remoting/zookeeper/curator_discovery/service_discovery.go b/remoting/zookeeper/curator_discovery/service_discovery.go index 9c7488bc2aab93959d5f9a3ab18e5c0a8d41d39b..5ab766895bbbaa2b4d34e2c2d6b2b4763ee72794 100644 --- a/remoting/zookeeper/curator_discovery/service_discovery.go +++ b/remoting/zookeeper/curator_discovery/service_discovery.go @@ -67,7 +67,7 @@ func NewServiceDiscovery(client *gxzookeeper.ZookeeperClient, basePath string) * // registerService register service to zookeeper func (sd *ServiceDiscovery) registerService(instance *ServiceInstance) error { - path := sd.pathForInstance(instance.Name, instance.Id) + path := sd.pathForInstance(instance.Name, instance.ID) data, err := json.Marshal(instance) if err != nil { return err @@ -91,7 +91,7 @@ func (sd *ServiceDiscovery) registerService(instance *ServiceInstance) error { // RegisterService register service to zookeeper, and ensure cache is consistent with zookeeper func (sd *ServiceDiscovery) RegisterService(instance *ServiceInstance) error { - value, loaded := sd.services.LoadOrStore(instance.Id, &Entry{}) + value, loaded := sd.services.LoadOrStore(instance.ID, &Entry{}) entry, ok := value.(*Entry) if !ok { return perrors.New("[ServiceDiscovery] services value not entry") @@ -104,16 +104,16 @@ func (sd *ServiceDiscovery) RegisterService(instance *ServiceInstance) error { return err } if !loaded { - sd.ListenServiceInstanceEvent(instance.Name, instance.Id, sd) + sd.ListenServiceInstanceEvent(instance.Name, instance.ID, sd) } return nil } // UpdateService update service in zookeeper, and ensure cache is consistent with zookeeper func (sd *ServiceDiscovery) UpdateService(instance *ServiceInstance) error { - value, ok := sd.services.Load(instance.Id) + value, ok := sd.services.Load(instance.ID) if !ok { - return perrors.Errorf("[ServiceDiscovery] Service{%s} not registered", instance.Id) + return perrors.Errorf("[ServiceDiscovery] Service{%s} not registered", instance.ID) } entry, ok := value.(*Entry) if !ok { @@ -127,7 +127,7 @@ func (sd *ServiceDiscovery) UpdateService(instance *ServiceInstance) error { entry.Lock() defer entry.Unlock() entry.instance = instance - path := sd.pathForInstance(instance.Name, instance.Id) + path := sd.pathForInstance(instance.Name, instance.ID) _, err = sd.client.SetContent(path, data, -1) if err != nil { @@ -158,17 +158,17 @@ func (sd *ServiceDiscovery) updateInternalService(name, id string) { // UnregisterService un-register service in zookeeper and delete service in cache func (sd *ServiceDiscovery) UnregisterService(instance *ServiceInstance) error { - _, ok := sd.services.Load(instance.Id) + _, ok := sd.services.Load(instance.ID) if !ok { return nil } - sd.services.Delete(instance.Id) + sd.services.Delete(instance.ID) return sd.unregisterService(instance) } // unregisterService un-register service in zookeeper func (sd *ServiceDiscovery) unregisterService(instance *ServiceInstance) error { - path := sd.pathForInstance(instance.Name, instance.Id) + path := sd.pathForInstance(instance.Name, instance.ID) return sd.client.Delete(path) } @@ -184,10 +184,10 @@ func (sd *ServiceDiscovery) ReRegisterServices() { instance := entry.instance err := sd.registerService(instance) if err != nil { - logger.Errorf("[zkServiceDiscovery] registerService{%s} error = err{%v}", instance.Id, perrors.WithStack(err)) + logger.Errorf("[zkServiceDiscovery] registerService{%s} error = err{%v}", instance.ID, perrors.WithStack(err)) return true } - sd.ListenServiceInstanceEvent(instance.Name, instance.Id, sd) + sd.ListenServiceInstanceEvent(instance.Name, instance.ID, sd) return true }) } @@ -245,7 +245,7 @@ func (sd *ServiceDiscovery) ListenServiceInstanceEvent(name, id string, listener // DataChange implement DataListener's DataChange function func (sd *ServiceDiscovery) DataChange(eventType remoting.Event) bool { path := eventType.Path - name, id, err := sd.getNameAndId(path) + name, id, err := sd.getNameAndID(path) if err != nil { logger.Errorf("[ServiceDiscovery] data change error = {%v}", err) return true @@ -254,8 +254,8 @@ func (sd *ServiceDiscovery) DataChange(eventType remoting.Event) bool { return true } -// getNameAndId get service name and instance id by path -func (sd *ServiceDiscovery) getNameAndId(path string) (string, string, error) { +// getNameAndID get service name and instance id by path +func (sd *ServiceDiscovery) getNameAndID(path string) (string, string, error) { path = strings.TrimPrefix(path, sd.basePath) path = strings.TrimPrefix(path, constant.PATH_SEPARATOR) pathSlice := strings.Split(path, constant.PATH_SEPARATOR) diff --git a/remoting/zookeeper/curator_discovery/service_instance.go b/remoting/zookeeper/curator_discovery/service_instance.go index f8d2bc723e0e0dd90ffdaa6ccd7c9908d65ac9a0..7acaf32f5627af6733b49da1692957a9af588ee6 100644 --- a/remoting/zookeeper/curator_discovery/service_instance.go +++ b/remoting/zookeeper/curator_discovery/service_instance.go @@ -21,7 +21,7 @@ package curator_discovery // https://github.com/apache/curator/blob/master/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/ServiceInstance.java type ServiceInstance struct { Name string - Id string + ID string Address string Port int Payload interface{} diff --git a/test/integrate/dubbo/go-client/user.go b/test/integrate/dubbo/go-client/user.go index ff4486f07975ebbb0064a8c83b71c952e6311dbb..e7e3347543c6baaf84b89b0eeaa843f510cad826 100644 --- a/test/integrate/dubbo/go-client/user.go +++ b/test/integrate/dubbo/go-client/user.go @@ -35,7 +35,7 @@ func init() { } type User struct { - Id string + ID string Name string Age int32 Time time.Time diff --git a/test/integrate/dubbo/go-server/user.go b/test/integrate/dubbo/go-server/user.go index aace76c1d2de93c2437ebe86943b5234c44a18d8..49601a24057307b5cab6d99fbb4d8e4121c0c50d 100644 --- a/test/integrate/dubbo/go-server/user.go +++ b/test/integrate/dubbo/go-server/user.go @@ -35,7 +35,7 @@ func init() { } type User struct { - Id string + ID string Name string Age int32 Time time.Time diff --git a/tools/cli/example/server/user.go b/tools/cli/example/server/user.go index 0bb25b545b64ff9d30e2e2572985c1f79d858d85..432f7f3576509852259e0c80109102859a66af59 100644 --- a/tools/cli/example/server/user.go +++ b/tools/cli/example/server/user.go @@ -48,7 +48,7 @@ func (u *UserProvider) Reference() string { } type User struct { - Id string + ID string Name string Age int32 SubInfo SubInfo