This PR refactors xds_client to support multiples watches. Those watches can be for the same type and same resource_name.
There's upper level `Client` and lower level `v2client`. Before this change, all logic was in `v2client`, and `Client` was a thin wrapper.
This PR moves some of the functionality from `v2client` to `Client`. New layers:
- Upper level `Client`
- keeps a list of watchers
- provides method `func WatchXXX() (cancel func())`
- has `WatchService()` which involves `LDS` and `RDS`
- handles resources from the xDS responses and dispatch to the watchers
- including multiple watchers for the same resource_name
- keeps cache
- and checks cache for new watches
- Lower level `v2client`
- is a dumb client that
- manages ADS stream
- sends a new xDS request when add/remove watch
- parses xDS responses
- It doesn't call watchers, but forwards all parsed results to upper Client
- handles ACK/NACK
- supports `addWatch(type, name)` and `removeWatch(type, name)`
- instead of `func watchCDS() func()`, which is now moved up to upper `Client`
Also includes other changes:
- Corresponding test changes (some tests for `v2client` were moved to `Client`)
- Method and type renaming
- CDS/EDS -> Cluster/Endpoints
- callback functions all accept updates as non-pointers
golint does check for missing package comment, but with low confidence.
golint checks each file, and complains on every file missing package comment, even though another file in the same package has the comment.
This PR adds a golint check with low min_confidence, and filters out false-positives.
This commit allows blocking clients to receive a more informative error
message than "context deadline exceeded", which is especially helpful in
tracking down persistent client misconfiguration (such as an invalid TLS
certificate, an invalid server that's refusing connections, etc.)
This can happen when the watch is canceled while the response is on wire.
Also, tag ACK/NACK with the stream so nonce for a new stream doesn't get updated by a ACK from the previous stream.
cmp.Equal is not supposed to be used in production code because of its
propensity towards panicking.
This equality will eventually be checked from the LB policy when it gets
a service config update.
This change only renames the type and reformats some comments. No change
in functionality. The rename was deemed necessary once I started
implementing the balancer and wanted to be consistent. The builder is
named `rlsBB`, the balancer is named `rlsBalancer`, so the picker should
be `rlsPicker`. Also, this rename allows the field in the balancer which
caches the last picker to be named `picker`.
1. Store the RLS server name (lookupService field) as a string instead
of as a resolver.Target as this is passed to grpc.Dial when creating
the control channel.
2. Store the default target specified in the ServiceConfig in a field in
the lbConfig struct.
3. Move some constants defined in builder.go to config.go because they
are only used in the latter.