tianxiaoliang commented on a change in pull request #804:
URL:
https://github.com/apache/servicecomb-service-center/pull/804#discussion_r551136300
##########
File path: datasource/mongo/system.go
##########
@@ -47,9 +48,11 @@ func (ds *DataSource) DUnlock(ctx context.Context, request
*datasource.DUnlockRe
func setServiceValue(e *sd.MongoCacher, setter dump.Setter) {
e.Cache().ForEach(func(k string, kv interface{}) (next bool) {
setter.SetValue(&dump.KV{
- Key:
util.StringJoin([]string{datasource.ServiceKeyPrefix, kv.(sd.Service).Domain,
- kv.(sd.Service).Project, k}, datasource.SPLIT),
- Value: kv.(sd.Service).ServiceInfo,
+ Key:
util.StringJoin([]string{datasource.ServiceKeyPrefix,
+ kv.(cache.Item).Object.(sd.Service).Domain,
Review comment:
kv.(cache.Item) 既然需要多次使用就应该只转换一次,然后再用,否则代码就会比较长
##########
File path: datasource/mongo/system.go
##########
@@ -47,9 +48,11 @@ func (ds *DataSource) DUnlock(ctx context.Context, request
*datasource.DUnlockRe
func setServiceValue(e *sd.MongoCacher, setter dump.Setter) {
e.Cache().ForEach(func(k string, kv interface{}) (next bool) {
setter.SetValue(&dump.KV{
- Key:
util.StringJoin([]string{datasource.ServiceKeyPrefix, kv.(sd.Service).Domain,
- kv.(sd.Service).Project, k}, datasource.SPLIT),
- Value: kv.(sd.Service).ServiceInfo,
+ Key:
util.StringJoin([]string{datasource.ServiceKeyPrefix,
+ kv.(cache.Item).Object.(sd.Service).Domain,
+ kv.(cache.Item).Object.(sd.Service).Project, k},
Review comment:
(sd.Service)同理
##########
File path: datasource/mongo/system.go
##########
@@ -58,9 +61,12 @@ func setServiceValue(e *sd.MongoCacher, setter dump.Setter) {
func setInstanceValue(e *sd.MongoCacher, setter dump.Setter) {
e.Cache().ForEach(func(k string, kv interface{}) (next bool) {
setter.SetValue(&dump.KV{
- Key:
util.StringJoin([]string{datasource.InstanceKeyPrefix, kv.(sd.Instance).Domain,
- kv.(sd.Instance).Project,
kv.(sd.Instance).InstanceInfo.ServiceId, k}, datasource.SPLIT),
- Value: kv.(sd.Instance).InstanceInfo,
+ Key:
util.StringJoin([]string{datasource.InstanceKeyPrefix,
+ kv.(cache.Item).Object.(sd.Instance).Domain,
Review comment:
(sd.Instance)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]