-
Notifications
You must be signed in to change notification settings - Fork 929
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
Add: DelegateMetadataReport & RemoteMetadataService #505
Conversation
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 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 |
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.
Using duration would be better
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 used by go-co-op/gocron. The param type is int64.
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
@@ -0,0 +1,46 @@ | |||
/* |
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.
is it just used for test case?
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.
yes
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 do not think it is a problem. Dubbo Java has many similar practices.
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 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
for _, m := range def.Methods { | ||
var paramType strings.Builder | ||
for _, p := range m.ParameterTypes { | ||
paramType.WriteString(fmt.Sprintf("{type:%v}", p)) |
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.
fmt.Fprintf(paramType, "{type:%v}", p) ?
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.
??
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 you wanna got its type, u should use %T
.
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 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) |
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.
dost UTC
need be set by users
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 does not involve specific time, but only requires the user to set interval time, so there is no problem of time zone difference.
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
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= |
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.
why import redis?
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 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)) |
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 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.") |
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 nonsense that writing a log without its context.
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.
type is just the variable's name. Not reflect.type meaning.
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 nonsense that writing a log without its context.
done
if bmr.syncReport { | ||
return report.SaveServiceMetadata(identifier, url) | ||
} | ||
go report.SaveServiceMetadata(identifier, url) |
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.
pls using gosafely in gost (https://github.com/dubbogo/gost/blob/8b727f60a1cb164b3e7797c7d3c78143771a4e70/runtime/goroutine.go#L29)
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 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) |
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.
pls using gosafely in gost
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.
As above.
if bmr.syncReport { | ||
return report.SaveSubscribedData(identifier, urls) | ||
} | ||
go report.SaveSubscribedData(identifier, urls) |
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.
pls using gosafely in gost
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.
As above.
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?: