Skip to content

Commit

Permalink
fix: change cluster Id to ID
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurenceLiZhixin committed Apr 4, 2022
1 parent aba60ca commit e41ea18
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
steps:
- uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: 1.15
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3.1.0
Expand Down
12 changes: 6 additions & 6 deletions cluster/router/meshrouter/meshrouter.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ func (r *MeshRouter) Route(invokers []protocol.Invoker, url *common.URL, invocat

clusterInvokerMap := make(map[string][]protocol.Invoker)
for _, v := range invokers {
meshClusterId := v.GetURL().GetParam(constant.MeshClusterIDKey, "")
if _, ok := clusterInvokerMap[meshClusterId]; !ok {
clusterInvokerMap[meshClusterId] = make([]protocol.Invoker, 0)
meshClusterID := v.GetURL().GetParam(constant.MeshClusterIDKey, "")
if _, ok := clusterInvokerMap[meshClusterID]; !ok {
clusterInvokerMap[meshClusterID] = make([]protocol.Invoker, 0)
}
clusterInvokerMap[meshClusterId] = append(clusterInvokerMap[meshClusterId], v)
clusterInvokerMap[meshClusterID] = append(clusterInvokerMap[meshClusterID], v)
}

if len(rconf.VirtualHosts) != 0 {
Expand Down Expand Up @@ -102,9 +102,9 @@ func (r *MeshRouter) Route(invokers []protocol.Invoker, url *common.URL, invocat
}
invokersWeightPairs := make(invokerWeightPairs, 0)

for clusterId, weight := range r.WeightedClusters {
for clusterID, weight := range r.WeightedClusters {
// cluster -> invokers
targetInvokers := clusterInvokerMap[clusterId]
targetInvokers := clusterInvokerMap[clusterID]
invokersWeightPairs = append(invokersWeightPairs, invokerWeightPair{
invokers: targetInvokers,
weight: weight.Weight,
Expand Down
2 changes: 1 addition & 1 deletion common/constant/xds.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package constant

const (
MeshClusterIDKey = "meshClusterId"
MeshClusterIDKey = "meshClusterID"
MeshHostAddrKey = "meshHostAddr"
MeshSubsetKey = "meshSubset"

Expand Down
10 changes: 5 additions & 5 deletions registry/directory/directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,11 @@ func (dir *RegistryDirectory) toGroupInvokers() []protocol.Invoker {
return groupInvokersList
}

func (dir *RegistryDirectory) uncacheInvokerWithClusterId(clusterId string) []protocol.Invoker {
logger.Debugf("All service will be deleted in cache invokers with clusterId %s!", clusterId)
func (dir *RegistryDirectory) uncacheInvokerWithClusterID(clusterID string) []protocol.Invoker {
logger.Debugf("All service will be deleted in cache invokers with clusterID %s!", clusterID)
invokerKeys := make([]string, 0)
dir.cacheInvokersMap.Range(func(key, cacheInvoker interface{}) bool {
if cacheInvoker.(protocol.Invoker).GetURL().GetParam(constant.MeshClusterIDKey, "") == clusterId {
if cacheInvoker.(protocol.Invoker).GetURL().GetParam(constant.MeshClusterIDKey, "") == clusterID {
invokerKeys = append(invokerKeys, key.(string))
}
return true
Expand All @@ -332,8 +332,8 @@ func (dir *RegistryDirectory) uncacheInvokerWithClusterId(clusterId string) []pr

// uncacheInvoker will return abandoned Invoker, if no Invoker to be abandoned, return nil
func (dir *RegistryDirectory) uncacheInvoker(event *registry.ServiceEvent) []protocol.Invoker {
if clusterId := event.Service.GetParam(constant.MeshClusterIDKey, ""); event.Service.Location == constant.MeshAnyAddrMatcher && clusterId != "" {
dir.uncacheInvokerWithClusterId(clusterId)
if clusterID := event.Service.GetParam(constant.MeshClusterIDKey, ""); event.Service.Location == constant.MeshAnyAddrMatcher && clusterID != "" {
dir.uncacheInvokerWithClusterID(clusterID)
}
return []protocol.Invoker{dir.uncacheInvokerWithKey(event.Key())}
}
Expand Down
2 changes: 1 addition & 1 deletion registry/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestKey(t *testing.T) {
se := ServiceEvent{
Service: u1,
}
assert.Equal(t, se.Key(), "dubbo://:@127.0.0.1:20000/?interface=com.ikurento.user.UserProvider&group=&version=2.0&timestamp=&meshClusterId=")
assert.Equal(t, se.Key(), "dubbo://:@127.0.0.1:20000/?interface=com.ikurento.user.UserProvider&group=&version=2.0&timestamp=&meshClusterID=")

se2 := ServiceEvent{
Service: u1,
Expand Down
2 changes: 1 addition & 1 deletion remoting/xds/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ type WrappedClientImpl struct {
rdsMapLock sync.RWMutex

/*
cdsMap cache full clusterId -> clusterUpdate map of this istiod
cdsMap cache full clusterID -> clusterUpdate map of this istiod
*/
cdsMap map[string]resource.ClusterUpdate
cdsMapLock sync.RWMutex
Expand Down
2 changes: 1 addition & 1 deletion remoting/xds/ewatcher/ewatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (watcher *endPointWatcherCtx) Destroy() {
watcher.cancel()
}
/*
directory would identify this by EndpointHealthStatusUnhealthy and Location == "*" and none empty clusterId
directory would identify this by EndpointHealthStatusUnhealthy and Location == "*" and none empty clusterID
and delete related invokers
*/
event := generateRegistryEvent(watcher.clusterName, resource.Endpoint{
Expand Down

0 comments on commit e41ea18

Please sign in to comment.