Fix: Id -> ID
diff --git a/config/config_loader.go b/config/config_loader.go
index bb1069c..cddccf4 100644
--- a/config/config_loader.go
+++ b/config/config_loader.go
@@ -340,7 +340,7 @@
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 a97018a..a2a1634 100644
--- a/config/reference_config.go
+++ b/config/reference_config.go
@@ -46,7 +46,7 @@
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 @@
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 @@
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 @@
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 f47bb4b..433d584 100644
--- a/config/reference_config_test.go
+++ b/config/reference_config_test.go
@@ -235,7 +235,7 @@
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 @@
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 @@
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 @@
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 @@
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) 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 @@
// 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 8e56d23..d35e87e 100644
--- a/config_center/nacos/impl.go
+++ b/config_center/nacos/impl.go
@@ -182,8 +182,8 @@
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 c253caf..5533945 100644
--- a/filter/filter_impl/auth/default_authenticator_test.go
+++ b/filter/filter_impl/auth/default_authenticator_test.go
@@ -44,7 +44,7 @@
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 9e68b64..e416abc 100644
--- a/filter/filter_impl/auth/provider_auth_test.go
+++ b/filter/filter_impl/auth/provider_auth_test.go
@@ -47,7 +47,7 @@
"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 69203e6..57f99b2 100644
--- a/filter/filter_impl/auth/sign_util_test.go
+++ b/filter/filter_impl/auth/sign_util_test.go
@@ -64,7 +64,7 @@
params := []interface{}{
"a", 1, struct {
Name string
- Id int64
+ ID int64
}{"YuYu", 1},
}
signature, _ := SignWithParams(params, metadata, key)
@@ -84,13 +84,13 @@
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 a032313..e387dee 100644
--- a/metadata/definition/definition.go
+++ b/metadata/definition/definition.go
@@ -57,13 +57,13 @@
}
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 @@
// 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 02f969c..65cef4e 100644
--- a/metadata/definition/mock.go
+++ b/metadata/definition/mock.go
@@ -23,7 +23,7 @@
)
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 5f62035..75c6677 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 @@
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 c697faf..523d55a 100644
--- a/metadata/service/inmemory/service_proxy_test.go
+++ b/metadata/service/inmemory/service_proxy_test.go
@@ -81,7 +81,7 @@
})
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 6edbab5..39cc46a 100644
--- a/metadata/service/remote/service_proxy_test.go
+++ b/metadata/service/remote/service_proxy_test.go
@@ -83,7 +83,7 @@
prepareTest()
ins := ®istry.DefaultServiceInstance{
- Id: "test-id",
+ ID: "test-id",
ServiceName: "com.dubbo",
Host: "localhost",
Port: 8080,
@@ -110,34 +110,34 @@
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 cfa81ca..a80fa4d 100644
--- a/protocol/dubbo/dubbo_invoker_test.go
+++ b/protocol/dubbo/dubbo_invoker_test.go
@@ -56,7 +56,7 @@
// 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 @@
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 @@
type (
User struct {
- Id string `json:"id"`
+ ID string `json:"id"`
Name string `json:"name"`
}
@@ -179,19 +179,19 @@
// 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) 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 e603b00..e7f2458 100644
--- a/protocol/dubbo/hessian2/hessian_dubbo_test.go
+++ b/protocol/dubbo/hessian2/hessian_dubbo_test.go
@@ -199,7 +199,7 @@
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 @@
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 caf0d22..4b5d125 100644
--- a/protocol/jsonrpc/http_test.go
+++ b/protocol/jsonrpc/http_test.go
@@ -39,7 +39,7 @@
type (
User struct {
- Id string `json:"id"`
+ ID string `json:"id"`
Name string `json:"name"`
}
@@ -82,7 +82,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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) 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 357443f..f194d6d 100644
--- a/protocol/jsonrpc/jsonrpc_invoker.go
+++ b/protocol/jsonrpc/jsonrpc_invoker.go
@@ -51,7 +51,7 @@
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 c604929..e5f242e 100644
--- a/protocol/jsonrpc/jsonrpc_invoker_test.go
+++ b/protocol/jsonrpc/jsonrpc_invoker_test.go
@@ -63,7 +63,7 @@
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 27c67db..70a9903 100644
--- a/protocol/rest/config/rest_config.go
+++ b/protocol/rest/config/rest_config.go
@@ -69,7 +69,7 @@
// 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 @@
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 5a5bd2c..4630d8e 100644
--- a/protocol/rest/rest_invoker_test.go
+++ b/protocol/rest/rest_invoker_test.go
@@ -172,14 +172,14 @@
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 4809564..f765a5d 100644
--- a/protocol/rest/rest_protocol_test.go
+++ b/protocol/rest/rest_protocol_test.go
@@ -130,7 +130,7 @@
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 @@
}
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 da5d8d0..6eba07d 100644
--- a/registry/consul/service_discovery.go
+++ b/registry/consul/service_discovery.go
@@ -216,12 +216,12 @@
}
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 @@
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 @@
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 @@
// 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 68e8042..e68223d 100644
--- a/registry/consul/service_discovery_test.go
+++ b/registry/consul/service_discovery_test.go
@@ -121,7 +121,7 @@
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 @@
"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 4979f1d..2448188 100644
--- a/registry/event/event_publishing_service_deiscovery_test.go
+++ b/registry/event/event_publishing_service_deiscovery_test.go
@@ -65,7 +65,7 @@
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 @@
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 ee2ad27..e827399 100644
--- a/registry/file/service_discovery_test.go
+++ b/registry/file/service_discovery_test.go
@@ -58,7 +58,7 @@
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 @@
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 785e395..f9e30d2 100644
--- a/registry/nacos/service_discovery.go
+++ b/registry/nacos/service_discovery.go
@@ -153,7 +153,7 @@
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 @@
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 @@
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 a9bc27b..98460b0 100644
--- a/registry/nacos/service_discovery_test.go
+++ b/registry/nacos/service_discovery_test.go
@@ -93,7 +93,7 @@
host := "host"
port := 123
instance := ®istry.DefaultServiceInstance{
- Id: id,
+ ID: id,
ServiceName: serviceName,
Host: host,
Port: port,
@@ -108,7 +108,7 @@
// clean data for local test
err = serviceDiscovery.Unregister(®istry.DefaultServiceInstance{
- Id: id,
+ ID: id,
ServiceName: serviceName,
Host: host,
Port: port,
@@ -129,7 +129,7 @@
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 43a1640..6802cc0 100644
--- a/registry/service_instance.go
+++ b/registry/service_instance.go
@@ -24,8 +24,8 @@
// 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 @@
// 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 @@
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 c53c058..ae04062 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 @@
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 @@
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 1bb38c9..93130d1 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 @@
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 @@
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 67c89a0..463016f 100644
--- a/registry/zookeeper/service_discovery.go
+++ b/registry/zookeeper/service_discovery.go
@@ -316,7 +316,7 @@
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) 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 @@
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 a73ecc9..aa3d770 100644
--- a/registry/zookeeper/service_discovery_test.go
+++ b/registry/zookeeper/service_discovery_test.go
@@ -86,7 +86,7 @@
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 @@
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 @@
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 @@
}()
err = sd.Register(®istry.DefaultServiceInstance{
- Id: "testId",
+ ID: "testID",
ServiceName: testName,
Host: "127.0.0.1",
Port: 2233,
@@ -178,7 +178,7 @@
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 @@
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 07dc549..06bcf52 100644
--- a/remoting/exchange.go
+++ b/remoting/exchange.go
@@ -45,9 +45,9 @@
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 @@
// The ID is auto increase.
func NewRequest(version string) *Request {
return &Request{
- ID: SequenceId(),
+ ID: SequenceID(),
Version: version,
}
}
@@ -142,7 +142,7 @@
}
// 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 41abe21..03cf581 100644
--- a/remoting/exchange_server.go
+++ b/remoting/exchange_server.go
@@ -32,14 +32,14 @@
// 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 3b59e9c..46d5b1c 100644
--- a/remoting/getty/getty_client_test.go
+++ b/remoting/getty/getty_client_test.go
@@ -122,7 +122,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
type (
User struct {
- Id string `json:"id"`
+ ID string `json:"id"`
Name string `json:"name"`
}
@@ -432,19 +432,19 @@
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) 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 db6dd8e..9fa3a32 100644
--- a/remoting/getty/readwriter_test.go
+++ b/remoting/getty/readwriter_test.go
@@ -163,7 +163,7 @@
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 9c7488b..5ab7668 100644
--- a/remoting/zookeeper/curator_discovery/service_discovery.go
+++ b/remoting/zookeeper/curator_discovery/service_discovery.go
@@ -67,7 +67,7 @@
// 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 @@
// 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 @@
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 @@
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 @@
// 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 @@
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 @@
// 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 @@
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 f8d2bc7..7acaf32 100644
--- a/remoting/zookeeper/curator_discovery/service_instance.go
+++ b/remoting/zookeeper/curator_discovery/service_instance.go
@@ -21,7 +21,7 @@
// 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 ff4486f..e7e3347 100644
--- a/test/integrate/dubbo/go-client/user.go
+++ b/test/integrate/dubbo/go-client/user.go
@@ -35,7 +35,7 @@
}
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 aace76c..49601a2 100644
--- a/test/integrate/dubbo/go-server/user.go
+++ b/test/integrate/dubbo/go-server/user.go
@@ -35,7 +35,7 @@
}
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 0bb25b5..432f7f3 100644
--- a/tools/cli/example/server/user.go
+++ b/tools/cli/example/server/user.go
@@ -48,7 +48,7 @@
}
type User struct {
- Id string
+ ID string
Name string
Age int32
SubInfo SubInfo