-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
xdsclient: update watcher API as per gRFC A88 #7977
base: master
Are you sure you want to change the base?
Conversation
8d198b7
to
a9b45c0
Compare
4009e3e
to
57dbf23
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7977 +/- ##
==========================================
+ Coverage 82.28% 82.45% +0.17%
==========================================
Files 381 388 +7
Lines 38539 39082 +543
==========================================
+ Hits 31712 32227 +515
Misses 5535 5535
- Partials 1292 1320 +28
|
43c9adb
to
89f475a
Compare
89f475a
to
a48b5bb
Compare
// will never be nil together. | ||
// | ||
// Watcher is expected to use the most recent value passed to | ||
// OnResourceChanged(), regardless of whether that's a resource or an error |
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.
Nit: s/ whether that's a resource/whether that's a ResourceData/
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.
Done
385ff44
to
1fdeb0d
Compare
@@ -58,27 +58,58 @@ type Producer interface { | |||
// from the xDS server. | |||
type OnDoneFunc func() | |||
|
|||
// ResourceDataOrError is a struct that contains either ResourceData or error. |
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.
Please skip the "is a struct" part.
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.
Done
// It is invoked under different error conditions including but not | ||
// limited to the following: | ||
// - authority mentioned in the resource is not found | ||
// - resource name parsing error | ||
// - resource deserialization error | ||
// - resource validation error | ||
// - ADS stream failure | ||
// - connection failure | ||
OnError(error, OnDoneFunc) | ||
|
||
// OnResourceDoesNotExist is invoked for a specific error condition where | ||
// the requested resource is not found on the xDS management server. | ||
OnResourceDoesNotExist(OnDoneFunc) | ||
// - authority mentioned in the resource is not found | ||
// - resource name parsing error | ||
// - resource validation error (if resource is not cached) | ||
// - ADS stream failure (if resource is not cached) | ||
// - connection failure (if resource is not cached) |
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 feel that the number of cases for which OnResourceChanged()
can be invoked are way too many now to be listing here. So, I feel we can get rid of this block completely. Wdyt?
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 have removed it. I have mentioned gRFC A88 at the top to refer for exhaustive list. I saw other places in code where we just mention the grfc and don't link. Also, the proposal is not merged yet.
One more i felt worth mentioning is about whether to continue reusing the existing resource or not. For OnResourceChanged(), they should stop using it.
// If resource is already cached, it is invoked under different error | ||
// conditions including but not limited to the following: | ||
// - resource validation error | ||
// - ADS stream failure | ||
// - connection failure |
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 also depends on a number of things like the server feature being set etc. So, I think we can get rid of this block as well. Somewhere in ResourceWatcher
documentation, we should link to A88 (probably at the top) and say that it contains an exhaustive list of what method is invoked under what conditions.
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.
Please update the documentation of the individual watchers as well based on the two comments here. Thanks.
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 have removed it. I have mentioned gRFC A88 at the top to refer for exhaustive list. I saw other places in code where we just mention the grfc and don't link. Also, the proposal is not merged yet.
One more i felt worth mentioning is about whether to continue reusing the existing resource or not. For OnAmbientError(), they may continue using it.
@easwars ptal |
This is the first part of implementing gRFC A88 (grpc/proposal#466).
This introduces the new watcher API but does not change any of the existing behavior. This table summarizes the API changes and behavior for each case:
OnResourceDoesNotExist()
OnResourceChanged(NOT_FOUND)
OnResourceDoesNotExist()
OnResourceChanged(NOT_FOUND)
OnError()
OnResourceChanged(status)
if resource NOT already cached;OnAmbientError(status)
otherwiseOnError()
OnResourceChanged(status)
if resource NOT already cached;OnAmbientError(status)
otherwiseOnError()
OnResourceChanged(status)
if resource NOT already cached;OnAmbientError(status)
otherwiseOnUpdate(resource)
OnResourceChanged(resource)
RELEASE NOTES: