blob: 2a95a669f0d47a988b2ca8e5ec7b79b0d232bd21 [file] [log] [blame]
Craig Tiller3bc8ebd2015-06-24 15:41:15 -07001/*
2 *
Craig Tiller6169d5f2016-03-31 07:46:18 -07003 * Copyright 2015, Google Inc.
Craig Tiller3bc8ebd2015-06-24 15:41:15 -07004 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following disclaimer
14 * in the documentation and/or other materials provided with the
15 * distribution.
16 * * Neither the name of Google Inc. nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */
33
Mark D. Roth15195742016-10-07 09:02:28 -070034#ifndef GRPC_CORE_EXT_CLIENT_CHANNEL_RESOLVER_REGISTRY_H
35#define GRPC_CORE_EXT_CLIENT_CHANNEL_RESOLVER_REGISTRY_H
Craig Tiller3bc8ebd2015-06-24 15:41:15 -070036
Mark D. Roth2137cd82016-09-14 09:04:00 -070037#include "src/core/ext/client_channel/resolver_factory.h"
Craig Tiller3bc8ebd2015-06-24 15:41:15 -070038
David Garcia Quintasfa0896b2016-09-23 16:10:19 -070039void grpc_resolver_registry_init();
Craig Tiller3bc8ebd2015-06-24 15:41:15 -070040void grpc_resolver_registry_shutdown(void);
41
David Garcia Quintasfa0896b2016-09-23 16:10:19 -070042/** Set the default URI prefix to \a default_prefix. */
43void grpc_resolver_registry_set_default_prefix(const char *default_prefix);
44
Craig Tiller3bc8ebd2015-06-24 15:41:15 -070045/** Register a resolver type.
46 URI's of \a scheme will be resolved with the given resolver.
47 If \a priority is greater than zero, then the resolver will be eligible
48 to resolve names that are passed in with no scheme. Higher priority
49 resolvers will be tried before lower priority schemes. */
Craig Tillerbc85be12015-08-24 10:36:39 -070050void grpc_register_resolver_type(grpc_resolver_factory *factory);
Craig Tiller3bc8ebd2015-06-24 15:41:15 -070051
Craig Tillerbc85be12015-08-24 10:36:39 -070052/** Create a resolver given \a target.
53 First tries to parse \a target as a URI. If this succeeds, tries
Craig Tillereb3b12e2015-06-26 14:42:49 -070054 to locate a registered resolver factory based on the URI scheme.
55 If parsing or location fails, prefixes default_prefix from
Craig Tillerbc85be12015-08-24 10:36:39 -070056 grpc_resolver_registry_init to target, and tries again (if default_prefix
Craig Tillereb3b12e2015-06-26 14:42:49 -070057 was not NULL).
58 If a resolver factory was found, use it to instantiate a resolver and
59 return it.
Mark D. Rothe917f5d2016-10-25 07:48:28 -070060 If a resolver factory was not found, return NULL.
61 \a args is a set of channel arguments to be included in the result
62 (typically the set of arguments passed in from the client API). */
Mark D. Roth98abfd32016-10-21 08:10:51 -070063grpc_resolver *grpc_resolver_create(const char *target,
Mark D. Roth557c9902016-10-24 11:12:05 -070064 const grpc_channel_args *args);
Craig Tillerbc85be12015-08-24 10:36:39 -070065
Craig Tiller65938df2016-03-31 13:08:49 -070066/** Find a resolver factory given a name and return an (owned-by-the-caller)
67 * reference to it */
68grpc_resolver_factory *grpc_resolver_factory_lookup(const char *name);
69
Craig Tillerbc85be12015-08-24 10:36:39 -070070/** Given a target, return a (freshly allocated with gpr_malloc) string
71 representing the default authority to pass from a client. */
72char *grpc_get_default_authority(const char *target);
Craig Tiller3bc8ebd2015-06-24 15:41:15 -070073
Mark D. Roth15195742016-10-07 09:02:28 -070074#endif /* GRPC_CORE_EXT_CLIENT_CHANNEL_RESOLVER_REGISTRY_H */