|
|
|
@ -414,15 +414,35 @@ void GoogleCloud2ProdResolver::StartXdsResolver() { |
|
|
|
|
|
|
|
|
|
class GoogleCloud2ProdResolverFactory : public ResolverFactory { |
|
|
|
|
public: |
|
|
|
|
// TODO(roth): Remove experimental suffix once this code is proven stable,
|
|
|
|
|
// and update the scheme in google_c2p_resolver_test.cc when doing so.
|
|
|
|
|
absl::string_view scheme() const override { return "google-c2p"; } |
|
|
|
|
|
|
|
|
|
bool IsValidUri(const URI& uri) const override { |
|
|
|
|
if (GPR_UNLIKELY(!uri.authority().empty())) { |
|
|
|
|
gpr_log(GPR_ERROR, "google-c2p URI scheme does not support authorities"); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
OrphanablePtr<Resolver> CreateResolver(ResolverArgs args) const override { |
|
|
|
|
if (!IsValidUri(args.uri)) return nullptr; |
|
|
|
|
return MakeOrphanable<GoogleCloud2ProdResolver>(std::move(args)); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// TODO(apolcyn): remove this class after user code has updated to the
|
|
|
|
|
// stable "google-c2p" URI scheme.
|
|
|
|
|
class ExperimentalGoogleCloud2ProdResolverFactory : public ResolverFactory { |
|
|
|
|
public: |
|
|
|
|
absl::string_view scheme() const override { |
|
|
|
|
return "google-c2p-experimental"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool IsValidUri(const URI& uri) const override { |
|
|
|
|
if (GPR_UNLIKELY(!uri.authority().empty())) { |
|
|
|
|
gpr_log(GPR_ERROR, "google-c2p URI scheme does not support authorities"); |
|
|
|
|
gpr_log( |
|
|
|
|
GPR_ERROR, |
|
|
|
|
"google-c2p-experimental URI scheme does not support authorities"); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
@ -439,6 +459,8 @@ class GoogleCloud2ProdResolverFactory : public ResolverFactory { |
|
|
|
|
void RegisterCloud2ProdResolver(CoreConfiguration::Builder* builder) { |
|
|
|
|
builder->resolver_registry()->RegisterResolverFactory( |
|
|
|
|
absl::make_unique<GoogleCloud2ProdResolverFactory>()); |
|
|
|
|
builder->resolver_registry()->RegisterResolverFactory( |
|
|
|
|
absl::make_unique<ExperimentalGoogleCloud2ProdResolverFactory>()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} // namespace grpc_core
|
|
|
|
|