-
Notifications
You must be signed in to change notification settings - Fork 933
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ftr: zk/consul Metadata #633
Conversation
Codecov Report
@@ Coverage Diff @@
## feature/dubbo-2.7.5 #633 +/- ##
=======================================================
- Coverage 65.98% 65.92% -0.07%
=======================================================
Files 204 207 +3
Lines 10604 10722 +118
=======================================================
+ Hits 6997 7068 +71
- Misses 2929 2972 +43
- Partials 678 682 +4
Continue to review full report at Codecov.
|
|
||
// StoreProviderMetadata stores the metadata. | ||
func (m *consulMetadataReport) StoreProviderMetadata(providerIdentifier *identifier.MetadataIdentifier, serviceDefinitions string) error { | ||
kv := &consul.KVPair{Key: providerIdentifier.GetIdentifierKey(), Value: []byte(serviceDefinitions)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
go fmt not work ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is ok with go fmt
.
metadata/report/consul/report.go
Outdated
k := metadataIdentifier.GetIdentifierKey() | ||
kv, _, err := m.client.KV().Get(k, nil) | ||
if err != nil { | ||
panic(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't panic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remove this panic and return an error in this function.
if err != nil { | ||
return perrors.WithMessage(err, "Could not convert the array to json") | ||
} | ||
|
||
report := instance.GetMetadataReportInstance() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This common logic may be confirmed by @flycash
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May create influence to nacos's implement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a common code for different metadata reports, and one can find the similar code in java version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep those codes, I will test it again
remoting/consul/agent.go
Outdated
@@ -0,0 +1,70 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What the consultAgent used for ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If used for unit test, it's better to move to xxx_test file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This consulAgent
is used for test, and is imported by other test, so I rename agent.go
to test_agent.go
. (xxx_test.go
can not be imported by other test.)
// GetSubscribedURLs gets the urls. | ||
func (m *consulMetadataReport) GetSubscribedURLs(subscriberMetadataIdentifier *identifier.SubscriberMetadataIdentifier) ([]string, error) { | ||
k := subscriberMetadataIdentifier.GetIdentifierKey() | ||
kv, _, err := m.client.KV().Get(k, nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if err != nil || kv == nil {
return emptyStrSlice, err
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I follow your advice and keep code more simpler.
if err != nil { | ||
return perrors.WithMessage(err, "Could not convert the array to json") | ||
} | ||
|
||
report := instance.GetMetadataReportInstance() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep those codes, I will test it again
metadata/report/zookeeper/report.go
Outdated
func (m *zookeeperMetadataReport) GetSubscribedURLs(subscriberMetadataIdentifier *identifier.SubscriberMetadataIdentifier) ([]string, error) { | ||
k := m.rootDir + subscriberMetadataIdentifier.GetFilePathKey() | ||
v, _, err := m.client.GetContent(k) | ||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I follow your advice and keep code more simpler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What this PR does:
Which issue(s) this PR fixes:
Fixes #445.
Special notes for your reviewer:
Does this PR introduce a user-facing change?: