Skip to content

xds: generic xds client #9444

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

Merged
merged 11 commits into from
Sep 16, 2022
Merged

xds: generic xds client #9444

merged 11 commits into from
Sep 16, 2022

Conversation

YifeiZhuang
Copy link
Member

@YifeiZhuang YifeiZhuang commented Aug 12, 2022

Get rid of type specific xds resources but making it generic, e.g.

  • Define abstract class XdsResourceType to be extended by pluggable new resources. It mainly contains abstract method doParse() to parse unpacked proto messges and produce a ResourceUpdate. The common unpacking proto logic is in XdsResourceType default method parse()
  • Move the parsing/processing logics to specific XdsResourceType. Implementing:
    • XdsListenerResource for LDS
    • XdsRouteConfigureResource for RDS
    • XdsClusterResource for CDS
    • XdsEndpointResource for EDS
  • The XdsResourceTypes are singleton. To process for each XdsClient, context is passed in parameters, defined by XdsResourceType.Args.
  • watchers will use generic APIs to subscribe to resource watchXdsResource(XdsResourceType, resourceName, watcher). Watcher and ResourceSubscribers becomes java generic class.

@YifeiZhuang YifeiZhuang requested a review from ejona86 August 16, 2022 20:28
@ejona86 ejona86 requested a review from sergiitk August 19, 2022 20:22
Copy link
Member

@sergiitk sergiitk left a comment

Choose a reason for hiding this comment

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

The review is still WIP, here's what I have so far.

@YifeiZhuang YifeiZhuang requested a review from sergiitk September 8, 2022 19:33
@YifeiZhuang
Copy link
Member Author

@ejona86 @sergiitk kind ping, any comments are welcome.

Copy link
Member

@ejona86 ejona86 left a comment

Choose a reason for hiding this comment

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

This looks good enough to me; it is big and we can do tweaks later. Except for the thread-safety of getInstance(); that needs to be fixed before it goes in.

private String rdsVersion = "";
private String cdsVersion = "";
private String edsVersion = "";
private final Map<ResourceType, String> versions = new HashMap<>();
Copy link
Member

Choose a reason for hiding this comment

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

FWIW, it looks trivial to use XdsResourceType as the key here (and the other map with ResourceType as the key). I did see the TODO for ResourceType, and that's okay, I just noticed those two maps seemed trivial.

@YifeiZhuang YifeiZhuang merged commit e1ad984 into grpc:master Sep 16, 2022
@YifeiZhuang YifeiZhuang deleted the generic-xds-api branch September 16, 2022 17:09
apolcyn added a commit to apolcyn/grpc-java that referenced this pull request Sep 22, 2022
larry-safran pushed a commit to larry-safran/grpc-java that referenced this pull request Oct 6, 2022
Mainly refactor work to make type specific xds resources generic, e.g.
1. Define abstract class XdsResourceType to be extended by pluggable new resources. It mainly contains abstract method doParse() to parse unpacked proto messges and produce a ResourceUpdate. The common unpacking proto logic is in XdsResourceType default method parse()
2. Move the parsing/processing logics to specific XdsResourceType. Implementing:
XdsListenerResource for LDS
XdsRouteConfigureResource for RDS
XdsClusterResource for CDS
XdsEndpointResource for EDS
3. The XdsResourceTypes are singleton. To process for each XdsClient, context is passed in parameters, defined by XdsResourceType.Args.
4. Watchers will use generic APIs to subscribe to resource watchXdsResource(XdsResourceType, resourceName, watcher). Watcher and ResourceSubscribers becomes java generic class.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants