-
Notifications
You must be signed in to change notification settings - Fork 4k
xds: add RlsClusterSpecifierPlugin for RLS-in-xDS #8612
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
+479
−46
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3ddcc35
xds: add RlsClusterSpecifierPlugin for RLS-in-xDS
dapengzhang0 ae87c38
AutoValue RlsPluginConfig for equals and hashCode
dapengzhang0 4dc78db
add javadoc for constructors to fix checkstyle
dapengzhang0 e413dcb
add javadoc for constructors to fix checkstyle
dapengzhang0 8f367ed
address comments
dapengzhang0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /* | ||
| * Copyright 2021 The gRPC Authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package io.grpc.xds; | ||
|
|
||
| import com.google.protobuf.Message; | ||
|
|
||
| /** | ||
| * Defines the parsing functionality of a ClusterSpecifierPlugin as defined in the Enovy proto | ||
| * api/envoy/config/route/v3/route.proto. | ||
| */ | ||
| interface ClusterSpecifierPlugin { | ||
| /** | ||
| * The proto message types supported by this plugin. A plugin will be registered by each of its | ||
| * supported message types. | ||
| */ | ||
| String[] typeUrls(); | ||
|
|
||
| ConfigOrError<? extends PluginConfig> parsePlugin(Message rawProtoMessage); | ||
|
|
||
| /** Represents an opaque data structure holding configuration for a ClusterSpecifierPlugin. */ | ||
| interface PluginConfig { | ||
| String typeUrl(); | ||
| } | ||
| } |
54 changes: 54 additions & 0 deletions
54
xds/src/main/java/io/grpc/xds/ClusterSpecifierPluginRegistry.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| /* | ||
| * Copyright 2021 The gRPC Authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package io.grpc.xds; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import javax.annotation.Nullable; | ||
|
|
||
| final class ClusterSpecifierPluginRegistry { | ||
| private static ClusterSpecifierPluginRegistry instance; | ||
|
|
||
| private final Map<String, ClusterSpecifierPlugin> supportedPlugins = new HashMap<>(); | ||
|
|
||
| private ClusterSpecifierPluginRegistry() {} | ||
|
|
||
| static synchronized ClusterSpecifierPluginRegistry getDefaultRegistry() { | ||
| if (instance == null) { | ||
| instance = newRegistry().register(RouteLookupServiceClusterSpecifierPlugin.INSTANCE); | ||
| } | ||
| return instance; | ||
| } | ||
|
|
||
| private static ClusterSpecifierPluginRegistry newRegistry() { | ||
| return new ClusterSpecifierPluginRegistry(); | ||
| } | ||
|
|
||
| private ClusterSpecifierPluginRegistry register(ClusterSpecifierPlugin... plugins) { | ||
| for (ClusterSpecifierPlugin plugin : plugins) { | ||
| for (String typeUrl : plugin.typeUrls()) { | ||
| supportedPlugins.put(typeUrl, plugin); | ||
| } | ||
| } | ||
| return this; | ||
| } | ||
|
|
||
| @Nullable | ||
| ClusterSpecifierPlugin get(String typeUrl) { | ||
| return supportedPlugins.get(typeUrl); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| /* | ||
| * Copyright 2021 The gRPC Authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package io.grpc.xds; | ||
|
|
||
| import static com.google.common.base.Preconditions.checkNotNull; | ||
|
|
||
| // TODO(zdapeng): Unify with ClientXdsClient.StructOrError, or just have parseFilterConfig() throw | ||
| // certain types of Exception. | ||
| final class ConfigOrError<T> { | ||
|
|
||
| /** | ||
| * Returns a {@link ConfigOrError} for the successfully converted data object. | ||
| */ | ||
| static <T> ConfigOrError<T> fromConfig(T config) { | ||
| return new ConfigOrError<>(config); | ||
| } | ||
|
|
||
| /** | ||
| * Returns a {@link ConfigOrError} for the failure to convert the data object. | ||
| */ | ||
| static <T> ConfigOrError<T> fromError(String errorDetail) { | ||
| return new ConfigOrError<>(errorDetail); | ||
| } | ||
|
|
||
| final String errorDetail; | ||
| final T config; | ||
|
|
||
| private ConfigOrError(T config) { | ||
| this.config = checkNotNull(config, "config"); | ||
| this.errorDetail = null; | ||
| } | ||
|
|
||
| private ConfigOrError(String errorDetail) { | ||
| this.config = null; | ||
| this.errorDetail = checkNotNull(errorDetail, "errorDetail"); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.