You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by ti...@apache.org on 2021/11/24 07:53:57 UTC
[servicecomb-service-center] branch master updated: Add query parameter "withShared" (#1168)
This is an automated email from the ASF dual-hosted git repository.
tianxiaoliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git
The following commit(s) were added to refs/heads/master by this push:
new 89fe81b Add query parameter "withShared" (#1168)
89fe81b is described below
commit 89fe81b98f03d25f1758b246b7043ba004768820
Author: humingcheng <hu...@163.com>
AuthorDate: Wed Nov 24 15:52:58 2021 +0800
Add query parameter "withShared" (#1168)
* Add query parameter "withShared" to control whether to return shared services, default: false.
* Improve instance health check interval in test case.
* Remove go-chassis v1 from go.mod
---
datasource/ms_util.go | 19 +++++
datasource/ms_util_test.go | 84 ++++++++++++++++++++++
docs/openapi/v4.yaml | 5 ++
go.mod | 4 +-
go.sum | 15 ++++
integration/instances_test.go | 4 +-
.../rest/controller/v4/microservice_controller.go | 4 +-
server/service/disco/microservice.go | 6 +-
server/service/govern/graph.go | 6 +-
9 files changed, 136 insertions(+), 11 deletions(-)
diff --git a/datasource/ms_util.go b/datasource/ms_util.go
index 16735e4..54df318 100644
--- a/datasource/ms_util.go
+++ b/datasource/ms_util.go
@@ -122,6 +122,25 @@ func IsGlobal(key *discovery.MicroServiceKey) bool {
return ok
}
+func RemoveGlobalServices(withShared bool, domainProject string,
+ services []*discovery.MicroService) []*discovery.MicroService {
+ if withShared || !IsDefaultDomainProject(domainProject) {
+ return services
+ }
+
+ for i := len(services) - 1; i >= 0; i-- {
+ if !IsGlobal(discovery.MicroServiceToKey(domainProject, services[i])) {
+ continue
+ }
+ if i == len(services)-1 {
+ services = services[0:i]
+ continue
+ }
+ services = append(services[0:i], services[i+1:]...)
+ }
+ return services
+}
+
func IsDefaultDomainProject(domainProject string) bool {
return domainProject == RegistryDomainProject
}
diff --git a/datasource/ms_util_test.go b/datasource/ms_util_test.go
index d58517c..f89f3fe 100644
--- a/datasource/ms_util_test.go
+++ b/datasource/ms_util_test.go
@@ -21,7 +21,9 @@ import (
"testing"
"github.com/apache/servicecomb-service-center/datasource"
+
"github.com/go-chassis/cari/discovery"
+ "github.com/stretchr/testify/assert"
)
func TestSetDefault(t *testing.T) {
@@ -32,3 +34,85 @@ func TestSetDefault(t *testing.T) {
t.Fatalf(`TestSetDefault failed`)
}
}
+
+func TestRemoveGlobalServices(t *testing.T) {
+ testGlobalServiceName := "RemoveGlobalServices"
+ datasource.RegisterGlobalService(testGlobalServiceName)
+ globalSvc := &discovery.MicroService{
+ AppId: datasource.RegistryAppID,
+ ServiceName: testGlobalServiceName,
+ }
+ noneGlobalSvc := &discovery.MicroService{
+ AppId: datasource.RegistryAppID,
+ ServiceName: "a",
+ }
+ //global Global
+ services := []*discovery.MicroService{globalSvc, noneGlobalSvc, globalSvc, noneGlobalSvc}
+ assert.True(t, hasGlobalService(services))
+ t.Run("withShared: true, should not remove global services", func(t *testing.T) {
+ s := datasource.RemoveGlobalServices(true, datasource.RegistryDomainProject, services)
+ assert.Equal(t, 4, len(s))
+ })
+ t.Run("withShared: false, but not default domain project, "+
+ "should not remove global services", func(t *testing.T) {
+ s := datasource.RemoveGlobalServices(false, "a/a", services)
+ assert.Equal(t, 4, len(s))
+ })
+ t.Run("withShared: false, default domain project, "+
+ "should remove global services", func(t *testing.T) {
+ s := datasource.RemoveGlobalServices(false, datasource.RegistryDomainProject, services)
+ assert.Equal(t, 2, len(s))
+ assert.False(t, hasGlobalService(s))
+ })
+ t.Run("remove global services", func(t *testing.T) {
+ t.Run("is global service: [no, no, no]", func(t *testing.T) {
+ services = []*discovery.MicroService{noneGlobalSvc, noneGlobalSvc, noneGlobalSvc}
+ s := datasource.RemoveGlobalServices(false, datasource.RegistryDomainProject, services)
+ assert.Equal(t, 3, len(s))
+ })
+ t.Run("is global service: [yes]", func(t *testing.T) {
+ services = []*discovery.MicroService{globalSvc}
+ s := datasource.RemoveGlobalServices(false, datasource.RegistryDomainProject, services)
+ assert.Equal(t, 0, len(s))
+ assert.False(t, hasGlobalService(s))
+ })
+ t.Run("is global service: [yes, yes, yes]", func(t *testing.T) {
+ services = []*discovery.MicroService{globalSvc, globalSvc, globalSvc}
+ s := datasource.RemoveGlobalServices(false, datasource.RegistryDomainProject, services)
+ assert.Equal(t, 0, len(s))
+ })
+ t.Run("is global service: [yes, yes, yes, no, no]", func(t *testing.T) {
+ services = []*discovery.MicroService{globalSvc, globalSvc, globalSvc, noneGlobalSvc, noneGlobalSvc}
+ s := datasource.RemoveGlobalServices(false, datasource.RegistryDomainProject, services)
+ assert.Equal(t, 2, len(s))
+ assert.False(t, hasGlobalService(s))
+ })
+ t.Run("is global service: [no, no, yes, yes]", func(t *testing.T) {
+ services = []*discovery.MicroService{noneGlobalSvc, noneGlobalSvc, globalSvc, globalSvc}
+ s := datasource.RemoveGlobalServices(false, datasource.RegistryDomainProject, services)
+ assert.Equal(t, 2, len(s))
+ assert.False(t, hasGlobalService(s))
+ })
+ t.Run("is global service: [no, no, yes, yes, no, no]", func(t *testing.T) {
+ services = []*discovery.MicroService{noneGlobalSvc, noneGlobalSvc, globalSvc, globalSvc, noneGlobalSvc, noneGlobalSvc}
+ s := datasource.RemoveGlobalServices(false, datasource.RegistryDomainProject, services)
+ assert.Equal(t, 4, len(s))
+ assert.False(t, hasGlobalService(s))
+ })
+ t.Run("is global service: [yes, no, no, yes, no, yes, yes]", func(t *testing.T) {
+ services = []*discovery.MicroService{globalSvc, noneGlobalSvc, noneGlobalSvc, globalSvc, noneGlobalSvc, globalSvc, globalSvc}
+ s := datasource.RemoveGlobalServices(false, datasource.RegistryDomainProject, services)
+ assert.Equal(t, 3, len(s))
+ assert.False(t, hasGlobalService(s))
+ })
+ })
+}
+
+func hasGlobalService(services []*discovery.MicroService) bool {
+ for _, s := range services {
+ if datasource.IsGlobal(discovery.MicroServiceToKey(datasource.RegistryDomainProject, s)) {
+ return true
+ }
+ }
+ return false
+}
diff --git a/docs/openapi/v4.yaml b/docs/openapi/v4.yaml
index cf7a930..5fad67c 100644
--- a/docs/openapi/v4.yaml
+++ b/docs/openapi/v4.yaml
@@ -169,6 +169,11 @@ paths:
in: path
required: true
type: string
+ - name: withShared
+ in: query
+ default: false
+ description: 控制返回信息中是否包含共享服务(例如SERVICECENTER);共享服务的domain为default,仅当该值为true且domain为default时,返回信息才会包含共享服务。
+ type: boolean
responses:
200:
description: 查询成功
diff --git a/go.mod b/go.mod
index 4fd4ef3..79e1181 100644
--- a/go.mod
+++ b/go.mod
@@ -13,10 +13,10 @@ require (
github.com/deckarep/golang-set v1.7.1
github.com/elithrar/simple-scrypt v1.3.0
github.com/ghodss/yaml v1.0.0
- github.com/go-chassis/cari v0.5.1-0.20210823023004-74041d1363c4
+ github.com/go-chassis/cari v0.5.1-0.20211124031617-99bda218b0cf
github.com/go-chassis/foundation v0.3.1-0.20210811025651-7f4d2b2b906c
github.com/go-chassis/go-archaius v1.5.1
- github.com/go-chassis/go-chassis-extension/protocol/grpc v0.0.0-20210902082902-eb5df922afcd // indirect
+ github.com/go-chassis/go-chassis-extension/protocol/grpc v0.0.0-20210902082902-eb5df922afcd
github.com/go-chassis/go-chassis/v2 v2.3.0
github.com/go-chassis/kie-client v0.1.1-0.20210926011742-97eed4281056
github.com/go-chassis/openlog v1.1.3
diff --git a/go.sum b/go.sum
index a49311b..8ac05d3 100644
--- a/go.sum
+++ b/go.sum
@@ -54,6 +54,7 @@ github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbt
github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M=
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
+github.com/Shonminh/apollo-client v0.2.0/go.mod h1:Jk6K99uIGxQm7Uyy1gCQTvM/kc1YLp4Qo9/jtGkEXvI=
github.com/Shonminh/apollo-client v0.4.0 h1:AXGp4wOahrEKjheMXehgsG9B8dEfLQHttRLHeEefvus=
github.com/Shonminh/apollo-client v0.4.0/go.mod h1:Jk6K99uIGxQm7Uyy1gCQTvM/kc1YLp4Qo9/jtGkEXvI=
github.com/Shopify/sarama v1.19.0 h1:9oksLxC6uxVPHPVYUmq6xhr1BOF/hHobWH2UzO67z1s=
@@ -225,6 +226,8 @@ github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkg
github.com/elithrar/simple-scrypt v1.3.0 h1:KIlOlxdoQf9JWKl5lMAJ28SY2URB0XTRDn2TckyzAZg=
github.com/elithrar/simple-scrypt v1.3.0/go.mod h1:U2XQRI95XHY0St410VE3UjT7vuKb1qPwrl/EJwEqnZo=
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
+github.com/emicklei/go-restful v2.8.0+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
+github.com/emicklei/go-restful v2.11.1+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
github.com/emicklei/go-restful v2.12.0+incompatible h1:SIvoTSbsMEwuM3dzFirLwKc4BH6VXP5CNf+G1FfJVr4=
github.com/emicklei/go-restful v2.12.0+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g=
@@ -267,18 +270,25 @@ github.com/go-chassis/cari v0.4.0/go.mod h1:av/19fqwEP4eOC8unL/z67AAbFDwXUCko6SK
github.com/go-chassis/cari v0.5.0/go.mod h1:av/19fqwEP4eOC8unL/z67AAbFDwXUCko6SKa4Avrd8=
github.com/go-chassis/cari v0.5.1-0.20210823023004-74041d1363c4 h1:FTbuN+IqSX17ulICGJqr357o8dGWqtfUdLtztLvIiRI=
github.com/go-chassis/cari v0.5.1-0.20210823023004-74041d1363c4/go.mod h1:av/19fqwEP4eOC8unL/z67AAbFDwXUCko6SKa4Avrd8=
+github.com/go-chassis/cari v0.5.1-0.20211124031617-99bda218b0cf h1:870QYgkSLFhpqGA8YuCRPazgdAKP4oqs5vs09A6d/gE=
+github.com/go-chassis/cari v0.5.1-0.20211124031617-99bda218b0cf/go.mod h1:av/19fqwEP4eOC8unL/z67AAbFDwXUCko6SKa4Avrd8=
+github.com/go-chassis/foundation v0.1.1-0.20191113114104-2b05871e9ec4/go.mod h1:21/ajGtgJlWTCeM0TxGJdRhO8bJkKirWyV8Stlh6g6c=
github.com/go-chassis/foundation v0.2.2-0.20201210043510-9f6d3de40234/go.mod h1:2PjwqpVwYEVaAldl5A58a08viH8p27pNeYaiE3ZxOBA=
github.com/go-chassis/foundation v0.2.2/go.mod h1:2PjwqpVwYEVaAldl5A58a08viH8p27pNeYaiE3ZxOBA=
github.com/go-chassis/foundation v0.3.0/go.mod h1:2PjwqpVwYEVaAldl5A58a08viH8p27pNeYaiE3ZxOBA=
github.com/go-chassis/foundation v0.3.1-0.20210806081520-3bd92d1ef787/go.mod h1:6NsIUaHghTFRGfCBcZN011zl196F6OR5QvD9N+P4oWU=
github.com/go-chassis/foundation v0.3.1-0.20210811025651-7f4d2b2b906c h1:6ooUyysnayGgoJHV++NLEcnnnXzsw3ud4VydjISGBqI=
github.com/go-chassis/foundation v0.3.1-0.20210811025651-7f4d2b2b906c/go.mod h1:6NsIUaHghTFRGfCBcZN011zl196F6OR5QvD9N+P4oWU=
+github.com/go-chassis/go-archaius v1.2.1/go.mod h1:gVP52u/jCU0fgUjXdUW1VLp5YLLJ+Yl2zoOPrLM/WOM=
github.com/go-chassis/go-archaius v1.5.1 h1:1FrNyzzmD6o6BIjPF8uQ4Cc+u7qYIgQTpDk8uopBqfo=
github.com/go-chassis/go-archaius v1.5.1/go.mod h1:QPwvvtBxvwiC48rmydoAqxopqOr93RCQ6syWsIkXPXQ=
+github.com/go-chassis/go-chassis v1.8.3 h1:abMUm489NF8wHqYtoY4KEN2Xy65og6R4NCS9KpxgpWI=
+github.com/go-chassis/go-chassis v1.8.3/go.mod h1:GTfwh1eXsOgMRFtLM7q8qSbceI+TsrkLL2UAS11Oey8=
github.com/go-chassis/go-chassis-extension/protocol/grpc v0.0.0-20210902082902-eb5df922afcd h1:RqGW+mW6U0+3QkvGXiDZfMwRb8PwW8bb1rI9tlm/jzo=
github.com/go-chassis/go-chassis-extension/protocol/grpc v0.0.0-20210902082902-eb5df922afcd/go.mod h1:btid7R4NKuET4BCUkR74CL5EP0hk3J0jXSByjzwd9JM=
github.com/go-chassis/go-chassis/v2 v2.3.0 h1:qqFeRhox9Ov0GMfkFnr/ZBkhjhyGHy+SrMyDNbXl8co=
github.com/go-chassis/go-chassis/v2 v2.3.0/go.mod h1:iyJ2DWSkqfnCmad/0Il9nXWHaob7RcwPGlIDRNxccH0=
+github.com/go-chassis/go-restful-swagger20 v1.0.2/go.mod h1:ZK4hlfS6Q6E46ViezAjn6atrzoteyWl1OBEpUBn/36k=
github.com/go-chassis/go-restful-swagger20 v1.0.3 h1:kWfeLwMwJZVkXP1zNyFpkmR41UZ55UTcOptTteXhvEs=
github.com/go-chassis/go-restful-swagger20 v1.0.3/go.mod h1:eW62fYuzlNFDvIacB6AV8bhUDCTy4myfTCv0bT9Gbb0=
github.com/go-chassis/kie-client v0.0.0-20201210060018-938c7680a9ab/go.mod h1:UTdbtyN5ge/v9DmQzdVRxQP7z51Q4z6hyl+W6ZpUHFM=
@@ -289,6 +299,7 @@ github.com/go-chassis/kie-client v0.1.1-0.20210926011742-97eed4281056/go.mod h1:
github.com/go-chassis/openlog v1.1.2/go.mod h1:+eYCADVxWyJkwsFMUBrMxyQlNqW+UUsCxvR2LrYZUaA=
github.com/go-chassis/openlog v1.1.3 h1:XqIOvZ8YPJ9o9lLtLBskQNNWolK5kC6a4Sv7r4s9sZ4=
github.com/go-chassis/openlog v1.1.3/go.mod h1:+eYCADVxWyJkwsFMUBrMxyQlNqW+UUsCxvR2LrYZUaA=
+github.com/go-chassis/paas-lager v1.0.2-0.20190328010332-cf506050ddb2/go.mod h1:tILYbn3+0jjCxhY6/ue9L8eRq+VJ60U6VYIdugqchB4=
github.com/go-chassis/sc-client v0.6.1-0.20210615014358-a45e9090c751 h1:hpWN/MZBMsnJqXdMkW7v0wsC+4rYulPsBFMrHCmZMQc=
github.com/go-chassis/sc-client v0.6.1-0.20210615014358-a45e9090c751/go.mod h1:TBS9g7OaIeu1OR/9tVPJEl6BgHFcYEdbuJlgVDQczbc=
github.com/go-chassis/seclog v1.3.0 h1:ofjF+GpDd7YFdxa6xk13brZfVSKMdZoQVPoCWjFHGUk=
@@ -310,6 +321,8 @@ github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG
github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas=
github.com/go-logr/logr v0.2.0 h1:QvGt2nLcHH0WK9orKa+ppBPAxREcH364nPUedEpK0TY=
github.com/go-logr/logr v0.2.0/go.mod h1:z6/tIYblkpsD+a4lm/fGIIU9mZ+XfAiaFtq7xTgseGU=
+github.com/go-mesh/openlogging v1.0.1 h1:6raaXo8SK+wuQX1VoNi6QJCSf1fTOFWh7f5f6b2ZEmY=
+github.com/go-mesh/openlogging v1.0.1/go.mod h1:qaKi+amO+hsGin2q1GmW+/NcbZpMPnTufwrWzDmIuuU=
github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0=
github.com/go-openapi/jsonpointer v0.19.3 h1:gihV7YNZK1iK6Tgwwsxo2rJbD1GTbdm72325Bq8FI3w=
github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
@@ -850,6 +863,7 @@ github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
+github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
@@ -1360,6 +1374,7 @@ k8s.io/kube-openapi v0.0.0-20200805222855-6aeccd4b50c6/go.mod h1:UuqjUnNftUyPE5H
k8s.io/kube-openapi v0.0.0-20210527164424-3c818078ee3d h1:lUK8GPtuJy8ClWZhuvKoaLdKGPLq9H1PxWp7VPBZBkU=
k8s.io/kube-openapi v0.0.0-20210527164424-3c818078ee3d/go.mod h1:vHXdDvt9+2spS2Rx9ql3I8tycm3H9FDfdUoIuKCefvw=
k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew=
+k8s.io/utils v0.0.0-20191114200735-6ca3b61696b6/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew=
k8s.io/utils v0.0.0-20200729134348-d5654de09c73 h1:uJmqzgNWG7XyClnU/mLPBWwfKKF1K8Hf8whTseBgJcg=
k8s.io/utils v0.0.0-20200729134348-d5654de09c73/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
rsc.io/binaryregexp v0.2.0 h1:HfqmD5MEmC0zvwBuF187nq9mdnXjXsSivRiXN7SmRkE=
diff --git a/integration/instances_test.go b/integration/instances_test.go
index 8e39140..f5ac910 100644
--- a/integration/instances_test.go
+++ b/integration/instances_test.go
@@ -239,8 +239,8 @@ var _ = Describe("MicroService Api Test", func() {
}
healthcheck := map[string]interface{}{
"mode": "push",
- "interval": 30,
- "times": 2,
+ "interval": 60,
+ "times": 3,
}
instance := map[string]interface{}{
"endpoints": endpoints,
diff --git a/server/rest/controller/v4/microservice_controller.go b/server/rest/controller/v4/microservice_controller.go
index a94d234..9548857 100644
--- a/server/rest/controller/v4/microservice_controller.go
+++ b/server/rest/controller/v4/microservice_controller.go
@@ -122,7 +122,9 @@ func (s *MicroServiceService) Unregister(w http.ResponseWriter, r *http.Request)
}
func (s *MicroServiceService) GetServices(w http.ResponseWriter, r *http.Request) {
- request := &pb.GetServicesRequest{}
+ request := &pb.GetServicesRequest{
+ WithShared: util.StringTRUE(r.URL.Query().Get("withShared")),
+ }
resp, err := core.ServiceAPI.GetServices(r.Context(), request)
if err != nil {
log.Error("get services failed", err)
diff --git a/server/service/disco/microservice.go b/server/service/disco/microservice.go
index ac7d55f..40215c3 100644
--- a/server/service/disco/microservice.go
+++ b/server/service/disco/microservice.go
@@ -202,7 +202,11 @@ func (s *MicroServiceService) GetOne(ctx context.Context, in *pb.GetServiceReque
}
func (s *MicroServiceService) GetServices(ctx context.Context, in *pb.GetServicesRequest) (*pb.GetServicesResponse, error) {
- return datasource.GetMetadataManager().GetServices(ctx, in)
+ resp, err := datasource.GetMetadataManager().GetServices(ctx, in)
+ if err == nil && len(resp.Services) > 0 {
+ resp.Services = datasource.RemoveGlobalServices(in.WithShared, util.ParseDomainProject(ctx), resp.Services)
+ }
+ return resp, err
}
func (s *MicroServiceService) UpdateProperties(ctx context.Context, in *pb.UpdateServicePropsRequest) (*pb.UpdateServicePropsResponse, error) {
diff --git a/server/service/govern/graph.go b/server/service/govern/graph.go
index 3c1b269..4ada006 100644
--- a/server/service/govern/graph.go
+++ b/server/service/govern/graph.go
@@ -65,7 +65,7 @@ type Graph struct {
func Draw(ctx context.Context, withShared bool) (*Graph, error) {
var graph Graph
- resp, err := core.ServiceAPI.GetServices(ctx, &discovery.GetServicesRequest{})
+ resp, err := core.ServiceAPI.GetServices(ctx, &discovery.GetServicesRequest{WithShared: withShared})
if err != nil {
return nil, discovery.NewError(discovery.ErrInternal, err.Error())
}
@@ -77,10 +77,6 @@ func Draw(ctx context.Context, withShared bool) (*Graph, error) {
domainProject := util.ParseDomainProject(ctx)
nodes := make([]Node, 0, len(services))
for _, service := range services {
- if isSkipped(withShared, domainProject, service) {
- continue
- }
-
var node Node
node.Name = service.ServiceName
node.ID = service.ServiceId