3 * Copyright 2015 gRPC authors.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_FACTORY_H
20 #define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_FACTORY_H
22 #include <grpc/support/port_platform.h>
24 #include <grpc/support/string_util.h>
26 #include "src/core/ext/filters/client_channel/resolver.h"
27 #include "src/core/lib/gprpp/abstract.h"
28 #include "src/core/lib/gprpp/memory.h"
29 #include "src/core/lib/gprpp/orphanable.h"
30 #include "src/core/lib/iomgr/pollset_set.h"
31 #include "src/core/lib/uri/uri_parser.h"
36 /// The parsed URI to resolve.
37 grpc_uri* uri = nullptr;
38 /// Channel args to be included in resolver results.
39 const grpc_channel_args* args = nullptr;
40 /// Used to drive I/O in the name resolution process.
41 grpc_pollset_set* pollset_set = nullptr;
42 /// The combiner under which all resolver calls will be run.
43 grpc_combiner* combiner = nullptr;
44 /// The result handler to be used by the resolver.
45 UniquePtr<Resolver::ResultHandler> result_handler;
48 class ResolverFactory {
50 /// Returns a bool indicating whether the input uri is valid to create a
52 virtual bool IsValidUri(const grpc_uri* uri) const GRPC_ABSTRACT;
54 /// Returns a new resolver instance.
55 virtual OrphanablePtr<Resolver> CreateResolver(ResolverArgs args) const
58 /// Returns a string representing the default authority to use for this
60 virtual UniquePtr<char> GetDefaultAuthority(grpc_uri* uri) const {
61 const char* path = uri->path;
62 if (path[0] == '/') ++path;
63 return UniquePtr<char>(gpr_strdup(path));
66 /// Returns the URI scheme that this factory implements.
67 /// Caller does NOT take ownership of result.
68 virtual const char* scheme() const GRPC_ABSTRACT;
70 virtual ~ResolverFactory() {}
72 GRPC_ABSTRACT_BASE_CLASS
75 } // namespace grpc_core
77 #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_FACTORY_H */