Craig Tiller | 3bc8ebd | 2015-06-24 15:41:15 -0700 | [diff] [blame] | 1 | /* |
| 2 | * |
Craig Tiller | 6169d5f | 2016-03-31 07:46:18 -0700 | [diff] [blame] | 3 | * Copyright 2015, Google Inc. |
Craig Tiller | 3bc8ebd | 2015-06-24 15:41:15 -0700 | [diff] [blame] | 4 | * 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. Roth | 1519574 | 2016-10-07 09:02:28 -0700 | [diff] [blame] | 34 | #ifndef GRPC_CORE_EXT_CLIENT_CHANNEL_RESOLVER_REGISTRY_H |
| 35 | #define GRPC_CORE_EXT_CLIENT_CHANNEL_RESOLVER_REGISTRY_H |
Craig Tiller | 3bc8ebd | 2015-06-24 15:41:15 -0700 | [diff] [blame] | 36 | |
Mark D. Roth | 2137cd8 | 2016-09-14 09:04:00 -0700 | [diff] [blame] | 37 | #include "src/core/ext/client_channel/resolver_factory.h" |
Yuchen Zeng | 63e3e3b | 2016-12-15 12:06:33 -0800 | [diff] [blame^] | 38 | #include "src/core/lib/iomgr/pollset_set.h" |
Craig Tiller | 3bc8ebd | 2015-06-24 15:41:15 -0700 | [diff] [blame] | 39 | |
David Garcia Quintas | fa0896b | 2016-09-23 16:10:19 -0700 | [diff] [blame] | 40 | void grpc_resolver_registry_init(); |
Craig Tiller | 3bc8ebd | 2015-06-24 15:41:15 -0700 | [diff] [blame] | 41 | void grpc_resolver_registry_shutdown(void); |
| 42 | |
David Garcia Quintas | fa0896b | 2016-09-23 16:10:19 -0700 | [diff] [blame] | 43 | /** Set the default URI prefix to \a default_prefix. */ |
| 44 | void grpc_resolver_registry_set_default_prefix(const char *default_prefix); |
| 45 | |
Craig Tiller | 3bc8ebd | 2015-06-24 15:41:15 -0700 | [diff] [blame] | 46 | /** Register a resolver type. |
| 47 | URI's of \a scheme will be resolved with the given resolver. |
| 48 | If \a priority is greater than zero, then the resolver will be eligible |
| 49 | to resolve names that are passed in with no scheme. Higher priority |
| 50 | resolvers will be tried before lower priority schemes. */ |
Craig Tiller | bc85be1 | 2015-08-24 10:36:39 -0700 | [diff] [blame] | 51 | void grpc_register_resolver_type(grpc_resolver_factory *factory); |
Craig Tiller | 3bc8ebd | 2015-06-24 15:41:15 -0700 | [diff] [blame] | 52 | |
Craig Tiller | bc85be1 | 2015-08-24 10:36:39 -0700 | [diff] [blame] | 53 | /** Create a resolver given \a target. |
| 54 | First tries to parse \a target as a URI. If this succeeds, tries |
Craig Tiller | eb3b12e | 2015-06-26 14:42:49 -0700 | [diff] [blame] | 55 | to locate a registered resolver factory based on the URI scheme. |
| 56 | If parsing or location fails, prefixes default_prefix from |
Craig Tiller | bc85be1 | 2015-08-24 10:36:39 -0700 | [diff] [blame] | 57 | grpc_resolver_registry_init to target, and tries again (if default_prefix |
Craig Tiller | eb3b12e | 2015-06-26 14:42:49 -0700 | [diff] [blame] | 58 | was not NULL). |
| 59 | If a resolver factory was found, use it to instantiate a resolver and |
| 60 | return it. |
Mark D. Roth | e917f5d | 2016-10-25 07:48:28 -0700 | [diff] [blame] | 61 | If a resolver factory was not found, return NULL. |
| 62 | \a args is a set of channel arguments to be included in the result |
| 63 | (typically the set of arguments passed in from the client API). */ |
Yuchen Zeng | 63e3e3b | 2016-12-15 12:06:33 -0800 | [diff] [blame^] | 64 | grpc_resolver *grpc_resolver_create(grpc_exec_ctx *exec_ctx, const char *target, |
| 65 | const grpc_channel_args *args, |
| 66 | grpc_pollset_set *pollset_set); |
Craig Tiller | bc85be1 | 2015-08-24 10:36:39 -0700 | [diff] [blame] | 67 | |
Craig Tiller | 65938df | 2016-03-31 13:08:49 -0700 | [diff] [blame] | 68 | /** Find a resolver factory given a name and return an (owned-by-the-caller) |
| 69 | * reference to it */ |
| 70 | grpc_resolver_factory *grpc_resolver_factory_lookup(const char *name); |
| 71 | |
Craig Tiller | bc85be1 | 2015-08-24 10:36:39 -0700 | [diff] [blame] | 72 | /** Given a target, return a (freshly allocated with gpr_malloc) string |
| 73 | representing the default authority to pass from a client. */ |
| 74 | char *grpc_get_default_authority(const char *target); |
Craig Tiller | 3bc8ebd | 2015-06-24 15:41:15 -0700 | [diff] [blame] | 75 | |
Mark D. Roth | 201db7d | 2016-12-12 09:36:02 -0800 | [diff] [blame] | 76 | /** Returns a newly allocated string containing \a target, adding the |
| 77 | default prefix if needed. */ |
| 78 | char *grpc_resolver_factory_add_default_prefix_if_needed(const char *target); |
| 79 | |
Mark D. Roth | 1519574 | 2016-10-07 09:02:28 -0700 | [diff] [blame] | 80 | #endif /* GRPC_CORE_EXT_CLIENT_CHANNEL_RESOLVER_REGISTRY_H */ |