Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Merge branch 'develop' into feat-3355-metadata-renew-and-gc
# Conflicts:
#	metadata/info/metadata_info.go
#	registry/servicediscovery/service_discovery_registry.go
  • Loading branch information
eye-gu committed Jun 25, 2026
commit a4895c4d3bb43b46342d345ec56c1ca01139fc73
4 changes: 4 additions & 0 deletions metadata/info/metadata_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ type MetadataInfo struct {
Services map[string]*ServiceInfo `json:"services,omitempty" hessian:"services"`
exportedServiceURLs map[string][]*common.URL `hessian:"-"` // server exported service urls
subscribedServiceURLs map[string][]*common.URL `hessian:"-"` // client subscribed service urls
mu sync.RWMutex `json:"-" hessian:"-"`
LastUpdatedTime int64 `json:"lastUpdatedTime,omitempty" hessian:"-"`
}

Expand Down Expand Up @@ -224,6 +225,9 @@ func (info *MetadataInfo) ReplaceExportedServices(urls []*common.URL) {
// Snapshot creates a deep copy of the MetadataInfo for safe concurrent access.
// The caller can modify the snapshot without affecting the original.
func (info *MetadataInfo) Snapshot() MetadataInfo {
info.mu.RLock()
defer info.mu.RUnlock()

services := make(map[string]*ServiceInfo, len(info.Services))
for k, v := range info.Services {
si := *v
Expand Down
1 change: 1 addition & 0 deletions registry/servicediscovery/service_discovery_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import (
"errors"
"math/rand/v2"
"sort"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -405,7 +406,7 @@

// ========== GC: stale revision cleanup ==========

func (s *serviceDiscoveryRegistry) doGarbageCollect() {

Check failure on line 409 in registry/servicediscovery/service_discovery_registry.go

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this method to reduce its Cognitive Complexity from 25 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=apache_dubbo-go&issues=AZ6WxS0F8Ft_Yw-VoyI6&open=AZ6WxS0F8Ft_Yw-VoyI6&pullRequest=3371
registryID := s.url.GetParam(constant.RegistryIdKey, "")
metaInfo := metadata.GetMetadataInfo(registryID)
if metaInfo == nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,18 @@ func (m *listenerMockMetadataReport) RemoveServiceAppMappingListener(string, str
return args.Error(0)
}

func (m *listenerMockMetadataReport) UnPublishAppMetadata(string, string) error {
return nil
}

func (m *listenerMockMetadataReport) ListAppRevisions(string) ([]metadatareport.AppRevision, error) {
return nil, nil
}

func (m *listenerMockMetadataReport) URL() *common.URL {
return nil
}

func newTestServiceInstance(t *testing.T, port int, environment string) registry.ServiceInstance {
t.Helper()

Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.