GRPC C++  1.39.1
resolver_factory.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_FACTORY_H
20 #define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_FACTORY_H
21 
23 
24 #include "absl/strings/strip.h"
25 
27 
33 
34 namespace grpc_core {
35 
36 struct ResolverArgs {
40  const grpc_channel_args* args = nullptr;
44  std::shared_ptr<WorkSerializer> work_serializer;
46  std::unique_ptr<Resolver::ResultHandler> result_handler;
47 };
48 
50  public:
53  virtual bool IsValidUri(const URI& uri) const = 0;
54 
57 
60  virtual std::string GetDefaultAuthority(const URI& uri) const {
61  return std::string(absl::StripPrefix(uri.path(), "/"));
62  }
63 
66  virtual const char* scheme() const = 0;
67 
68  virtual ~ResolverFactory() {}
69 };
70 
71 } // namespace grpc_core
72 
73 #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_FACTORY_H */
Definition: resolver_factory.h:49
virtual bool IsValidUri(const URI &uri) const =0
Returns a bool indicating whether the input uri is valid to create a resolver.
virtual ~ResolverFactory()
Definition: resolver_factory.h:68
virtual std::string GetDefaultAuthority(const URI &uri) const
Returns a string representing the default authority to use for this scheme.
Definition: resolver_factory.h:60
virtual OrphanablePtr< Resolver > CreateResolver(ResolverArgs args) const =0
Returns a new resolver instance.
virtual const char * scheme() const =0
Returns the URI scheme that this factory implements.
Definition: uri_parser.h:35
const std::string & path() const
Definition: uri_parser.h:61
Round Robin Policy.
Definition: backend_metric.cc:26
std::unique_ptr< T, Deleter > OrphanablePtr
Definition: orphanable.h:67
struct grpc_pollset_set grpc_pollset_set
Definition: pollset_set.h:31
An array of arguments that can be passed around.
Definition: grpc_types.h:132
Definition: resolver_factory.h:36
const grpc_channel_args * args
Channel args to be included in resolver results.
Definition: resolver_factory.h:40
std::shared_ptr< WorkSerializer > work_serializer
The work_serializer under which all resolver calls will be run.
Definition: resolver_factory.h:44
grpc_pollset_set * pollset_set
Used to drive I/O in the name resolution process.
Definition: resolver_factory.h:42
URI uri
The parsed URI to resolve.
Definition: resolver_factory.h:38
std::unique_ptr< Resolver::ResultHandler > result_handler
The result handler to be used by the resolver.
Definition: resolver_factory.h:46