resolver_factory.h
Go to the documentation of this file.
1 //
2 // Copyright 2015 gRPC authors.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 #ifndef GRPC_CORE_LIB_RESOLVER_RESOLVER_FACTORY_H
18 #define GRPC_CORE_LIB_RESOLVER_RESOLVER_FACTORY_H
19 
21 
22 #include <memory>
23 #include <string>
24 
25 #include "absl/strings/string_view.h"
26 #include "absl/strings/strip.h"
27 
29 
34 
35 namespace grpc_core {
36 
37 // TODO(yashkt): Move WorkSerializer to its own Bazel target, depend on that
38 // target from this one, and remove this forward declaration.
39 class WorkSerializer;
40 
41 struct ResolverArgs {
45  const grpc_channel_args* args = nullptr;
49  std::shared_ptr<WorkSerializer> work_serializer;
51  std::unique_ptr<Resolver::ResultHandler> result_handler;
52 };
53 
55  public:
56  virtual ~ResolverFactory() {}
57 
60  virtual absl::string_view scheme() const = 0;
61 
64  virtual bool IsValidUri(const URI& uri) const = 0;
65 
68 
71  virtual std::string GetDefaultAuthority(const URI& uri) const {
72  return std::string(absl::StripPrefix(uri.path(), "/"));
73  }
74 };
75 
76 } // namespace grpc_core
77 
78 #endif // GRPC_CORE_LIB_RESOLVER_RESOLVER_FACTORY_H
orphanable.h
grpc_core::ResolverFactory::CreateResolver
virtual OrphanablePtr< Resolver > CreateResolver(ResolverArgs args) const =0
Returns a new resolver instance.
grpc_core
Definition: call_metric_recorder.h:31
grpc_pollset_set
struct grpc_pollset_set grpc_pollset_set
Definition: iomgr_fwd.h:23
absl::string_view
Definition: abseil-cpp/absl/strings/string_view.h:167
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
grpc_core::URI
Definition: uri_parser.h:31
grpc_core::ResolverFactory::GetDefaultAuthority
virtual std::string GetDefaultAuthority(const URI &uri) const
Definition: resolver_factory.h:71
absl::StripPrefix
ABSL_MUST_USE_RESULT absl::string_view StripPrefix(absl::string_view str, absl::string_view prefix)
Definition: abseil-cpp/absl/strings/strip.h:73
grpc_core::ResolverFactory::IsValidUri
virtual bool IsValidUri(const URI &uri) const =0
grpc_channel_args
Definition: grpc_types.h:132
grpc_core::URI::path
const std::string & path() const
Definition: uri_parser.h:70
grpc_types.h
asyncio_get_stats.args
args
Definition: asyncio_get_stats.py:40
grpc_core::ResolverArgs::args
const grpc_channel_args * args
Channel args to be included in resolver results.
Definition: resolver_factory.h:45
grpc_core::ResolverArgs
Definition: resolver_factory.h:41
grpc_core::ResolverFactory::~ResolverFactory
virtual ~ResolverFactory()
Definition: resolver_factory.h:56
resolver.h
grpc_core::ResolverArgs::uri
URI uri
The parsed URI to resolve.
Definition: resolver_factory.h:43
grpc_core::OrphanablePtr
std::unique_ptr< T, Deleter > OrphanablePtr
Definition: orphanable.h:64
grpc_core::ResolverArgs::pollset_set
grpc_pollset_set * pollset_set
Used to drive I/O in the name resolution process.
Definition: resolver_factory.h:47
grpc_core::ResolverArgs::work_serializer
std::shared_ptr< WorkSerializer > work_serializer
The work_serializer under which all resolver calls will be run.
Definition: resolver_factory.h:49
uri_parser.h
iomgr_fwd.h
grpc_core::ResolverFactory::scheme
virtual absl::string_view scheme() const =0
grpc_core::ResolverFactory
Definition: resolver_factory.h:54
grpc_core::ResolverArgs::result_handler
std::unique_ptr< Resolver::ResultHandler > result_handler
The result handler to be used by the resolver.
Definition: resolver_factory.h:51
port_platform.h


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:11