Skip to content
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

Add: DelegateMetadataReport & RemoteMetadataService #505

Merged
merged 9 commits into from
May 25, 2020

Conversation

hxmhlt
Copy link
Contributor

@hxmhlt hxmhlt commented May 6, 2020

What this PR does:

1.Finish delegate metadata report as all metadata report implements father.
2.Finish remote metadata service to implement MetadataService interface.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


Copy link
Member

@flycash flycash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that you convert the MetadataReportConfig to URL, and then read params from URL.So why don't you use MetadataReportConfig directly?


// metadataReportRetry is a scheduler for retrying task
type metadataReportRetry struct {
retryPeriod int64
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using duration would be better

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is used by go-co-op/gocron. The param type is int64.

config/instance/metedata_report.go Outdated Show resolved Hide resolved
metadata/service/inmemory/service.go Outdated Show resolved Hide resolved
metadata/service/remote/service.go Outdated Show resolved Hide resolved
metadata/service/service.go Outdated Show resolved Hide resolved
metadata/definition/definition.go Outdated Show resolved Hide resolved
metadata/definition/definition.go Outdated Show resolved Hide resolved
metadata/definition/definition.go Outdated Show resolved Hide resolved
metadata/report/delegate/delegate_report.go Outdated Show resolved Hide resolved
metadata/report/delegate/delegate_report_test.go Outdated Show resolved Hide resolved
metadata/report/delegate/delegate_report_test.go Outdated Show resolved Hide resolved
metadata/definition/definition.go Outdated Show resolved Hide resolved
metadata/report/delegate/delegate_report_test.go Outdated Show resolved Hide resolved
metadata/service/remote/service.go Outdated Show resolved Hide resolved
@codecov-io
Copy link

codecov-io commented May 17, 2020

Codecov Report

Merging #505 into feature/dubbo-2.7.5 will decrease coverage by 0.69%.
The diff coverage is 43.70%.

Impacted file tree graph

@@                   Coverage Diff                   @@
##           feature/dubbo-2.7.5     #505      +/-   ##
=======================================================
- Coverage                66.66%   65.96%   -0.70%     
=======================================================
  Files                      199      203       +4     
  Lines                    10212    10487     +275     
=======================================================
+ Hits                      6808     6918     +110     
- Misses                    2751     2901     +150     
- Partials                   653      668      +15     
Impacted Files Coverage Δ
metadata/identifier/service_metadata_identifier.go 30.76% <0.00%> (-69.24%) ⬇️
...tadata/identifier/subscribe_metadata_identifier.go 100.00% <ø> (ø)
metadata/definition/mock.go 28.57% <28.57%> (ø)
metadata/report/delegate/delegate_report.go 41.08% <41.08%> (ø)
metadata/service/remote/service.go 43.95% <43.95%> (ø)
metadata/definition/definition.go 58.97% <62.50%> (ø)
metadata/service/inmemory/service.go 87.03% <70.58%> (ø)
metadata/service/exporter/configurable/exporter.go 94.59% <100.00%> (ø)
config_center/nacos/facade.go 37.50% <0.00%> (-25.00%) ⬇️
config_center/nacos/client.go 55.55% <0.00%> (-1.71%) ⬇️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c958389...235edf5. Read the comment docs.

metadata/report/delegate/delegate_report.go Outdated Show resolved Hide resolved
metadata/report/delegate/delegate_report.go Outdated Show resolved Hide resolved
metadata/report/delegate/delegate_report.go Outdated Show resolved Hide resolved
@@ -0,0 +1,46 @@
/*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it just used for test case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think it is a problem. Dubbo Java has many similar practices.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If just for test ,then i think that is a problem, because it can be use out of test case .

what do you think ? @flycash @fangyincheng @AlexStocks

metadata/definition/definition.go Outdated Show resolved Hide resolved
metadata/definition/definition.go Outdated Show resolved Hide resolved
for _, m := range def.Methods {
var paramType strings.Builder
for _, p := range m.ParameterTypes {
paramType.WriteString(fmt.Sprintf("{type:%v}", p))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fmt.Fprintf(paramType, "{type:%v}", p) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

??

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you wanna got its type, u should use %T.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you wanna got its type, u should use %T.

type is just the variable's name. Not reflect.type meaning.


// newMetadataReportRetry will create a scheduler for retry task
func newMetadataReportRetry(retryPeriod int64, retryLimit int64, retryFunc func() bool) (*metadataReportRetry, error) {
s1 := gocron.NewScheduler(time.UTC)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dost UTC need be set by users

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not involve specific time, but only requires the user to set interval time, so there is no problem of time zone difference.

@codecov-commenter
Copy link

codecov-commenter commented May 23, 2020

Codecov Report

Merging #505 into feature/dubbo-2.7.5 will decrease coverage by 0.81%.
The diff coverage is 39.19%.

Impacted file tree graph

@@                   Coverage Diff                   @@
##           feature/dubbo-2.7.5     #505      +/-   ##
=======================================================
- Coverage                66.66%   65.85%   -0.82%     
=======================================================
  Files                      199      203       +4     
  Lines                    10212    10558     +346     
=======================================================
+ Hits                      6808     6953     +145     
- Misses                    2751     2935     +184     
- Partials                   653      670      +17     
Impacted Files Coverage Δ
metadata/identifier/service_metadata_identifier.go 30.76% <0.00%> (-69.24%) ⬇️
...tadata/identifier/subscribe_metadata_identifier.go 100.00% <ø> (ø)
metadata/definition/mock.go 28.57% <28.57%> (ø)
metadata/report/delegate/delegate_report.go 30.76% <30.76%> (ø)
metadata/service/remote/service.go 43.95% <43.95%> (ø)
metadata/definition/definition.go 58.97% <66.66%> (ø)
metadata/service/inmemory/service.go 87.03% <70.58%> (ø)
metadata/service/exporter/configurable/exporter.go 94.59% <100.00%> (ø)
cluster/cluster_impl/base_cluster_invoker.go 62.31% <0.00%> (-10.15%) ⬇️
registry/etcdv3/registry.go 69.01% <0.00%> (-4.13%) ⬇️
... and 12 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c958389...c024ce1. Read the comment docs.

@gaoxinge
Copy link

Nice job! LGTM.

@@ -153,6 +151,7 @@ github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+
github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg=
github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc=
github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I=
github.com/go-redis/redis v6.15.5+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why import redis?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I import go-cron lib and redis lib is imported.

for _, m := range def.Methods {
var paramType strings.Builder
for _, p := range m.ParameterTypes {
paramType.WriteString(fmt.Sprintf("{type:%v}", p))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you wanna got its type, u should use %T.

scheduler := gocron.NewScheduler(time.UTC)
_, err := scheduler.Every(1).Day().Do(
func() {
logger.Info("start to publish all metadata.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is nonsense that writing a log without its context.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type is just the variable's name. Not reflect.type meaning.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is nonsense that writing a log without its context.

done

metadata/report/delegate/delegate_report.go Outdated Show resolved Hide resolved
metadata/report/delegate/delegate_report.go Outdated Show resolved Hide resolved
metadata/report/delegate/delegate_report.go Outdated Show resolved Hide resolved
if bmr.syncReport {
return report.SaveServiceMetadata(identifier, url)
}
go report.SaveServiceMetadata(identifier, url)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@hxmhlt hxmhlt May 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the panic should be recover by the func called. Because we don't know what should we do because SaveServiceMetadata method is provided by extension metadata like ZooKeeper, etcd and so on. They should provider their error handler method.

if bmr.syncReport {
return report.RemoveServiceMetadata(identifier)
}
go report.RemoveServiceMetadata(identifier)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls using gosafely in gost

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above.

if bmr.syncReport {
return report.SaveSubscribedData(identifier, urls)
}
go report.SaveSubscribedData(identifier, urls)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls using gosafely in gost

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above.

metadata/service/remote/service.go Outdated Show resolved Hide resolved
@AlexStocks AlexStocks merged commit d4c83fb into apache:feature/dubbo-2.7.5 May 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants