AlexStocks commented on a change in pull request #1221:
URL: https://github.com/apache/dubbo-go/pull/1221#discussion_r644868683
##########
File path: metadata/report/etcd/report.go
##########
@@ -52,14 +53,28 @@ type etcdMetadataReport struct {
// GetAppMetadata get metadata info from etcd
func (e *etcdMetadataReport) GetAppMetadata(metadataIdentifier
*identifier.SubscriberMetadataIdentifier) (*common.MetadataInfo, error) {
- // TODO will implement
- panic("implement me")
+ key := e.getNodeKey(metadataIdentifier)
+ data, err := e.client.Get(key)
+ if err != nil {
+ return nil, err
+ }
+ info := &common.MetadataInfo{}
+ err = json.Unmarshal([]byte(data), info)
Review comment:
pls delete the following 4 line codes. `return info, err` is just enough.
##########
File path: metadata/report/etcd/report.go
##########
@@ -52,14 +53,28 @@ type etcdMetadataReport struct {
// GetAppMetadata get metadata info from etcd
func (e *etcdMetadataReport) GetAppMetadata(metadataIdentifier
*identifier.SubscriberMetadataIdentifier) (*common.MetadataInfo, error) {
- // TODO will implement
- panic("implement me")
+ key := e.getNodeKey(metadataIdentifier)
+ data, err := e.client.Get(key)
+ if err != nil {
+ return nil, err
+ }
+ info := &common.MetadataInfo{}
+ err = json.Unmarshal([]byte(data), info)
+ if err != nil {
+ return nil, err
+ }
+ return info, nil
}
// PublishAppMetadata publish metadata info to etcd
func (e *etcdMetadataReport) PublishAppMetadata(metadataIdentifier
*identifier.SubscriberMetadataIdentifier, info *common.MetadataInfo) error {
- // TODO will implement
- panic("implement me")
+ key := e.getNodeKey(metadataIdentifier)
Review comment:
```go
key := e.getNodeKey(metadataIdentifier)
value, err := json.Marshal(info)
if err == nil {
err = e.client.Put(key, string(value))
}
return err
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]