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 | |
Craig Tiller | 9a4dddd | 2016-03-25 17:08:13 -0700 | [diff] [blame] | 34 | #ifndef GRPC_CORE_LIB_CLIENT_CONFIG_RESOLVER_REGISTRY_H |
| 35 | #define GRPC_CORE_LIB_CLIENT_CONFIG_RESOLVER_REGISTRY_H |
Craig Tiller | 3bc8ebd | 2015-06-24 15:41:15 -0700 | [diff] [blame] | 36 | |
Craig Tiller | 9533d04 | 2016-03-25 17:11:06 -0700 | [diff] [blame] | 37 | #include "src/core/lib/client_config/resolver_factory.h" |
Craig Tiller | 3bc8ebd | 2015-06-24 15:41:15 -0700 | [diff] [blame] | 38 | |
Craig Tiller | eb3b12e | 2015-06-26 14:42:49 -0700 | [diff] [blame] | 39 | void grpc_resolver_registry_init(const char *default_prefix); |
Craig Tiller | 3bc8ebd | 2015-06-24 15:41:15 -0700 | [diff] [blame] | 40 | void grpc_resolver_registry_shutdown(void); |
| 41 | |
| 42 | /** Register a resolver type. |
| 43 | URI's of \a scheme will be resolved with the given resolver. |
| 44 | If \a priority is greater than zero, then the resolver will be eligible |
| 45 | to resolve names that are passed in with no scheme. Higher priority |
| 46 | resolvers will be tried before lower priority schemes. */ |
Craig Tiller | bc85be1 | 2015-08-24 10:36:39 -0700 | [diff] [blame] | 47 | void grpc_register_resolver_type(grpc_resolver_factory *factory); |
Craig Tiller | 3bc8ebd | 2015-06-24 15:41:15 -0700 | [diff] [blame] | 48 | |
Craig Tiller | bc85be1 | 2015-08-24 10:36:39 -0700 | [diff] [blame] | 49 | /** Create a resolver given \a target. |
| 50 | 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] | 51 | to locate a registered resolver factory based on the URI scheme. |
| 52 | If parsing or location fails, prefixes default_prefix from |
Craig Tiller | bc85be1 | 2015-08-24 10:36:39 -0700 | [diff] [blame] | 53 | grpc_resolver_registry_init to target, and tries again (if default_prefix |
Craig Tiller | eb3b12e | 2015-06-26 14:42:49 -0700 | [diff] [blame] | 54 | was not NULL). |
| 55 | If a resolver factory was found, use it to instantiate a resolver and |
| 56 | return it. |
| 57 | If a resolver factory was not found, return NULL. */ |
Craig Tiller | 3bc8ebd | 2015-06-24 15:41:15 -0700 | [diff] [blame] | 58 | grpc_resolver *grpc_resolver_create( |
David Garcia Quintas | fcf7ad6 | 2016-03-29 21:55:34 -0700 | [diff] [blame] | 59 | const char *target, grpc_client_channel_factory *client_channel_factory); |
Craig Tiller | bc85be1 | 2015-08-24 10:36:39 -0700 | [diff] [blame] | 60 | |
Craig Tiller | 65938df | 2016-03-31 13:08:49 -0700 | [diff] [blame] | 61 | /** Find a resolver factory given a name and return an (owned-by-the-caller) |
| 62 | * reference to it */ |
| 63 | grpc_resolver_factory *grpc_resolver_factory_lookup(const char *name); |
| 64 | |
Craig Tiller | bc85be1 | 2015-08-24 10:36:39 -0700 | [diff] [blame] | 65 | /** Given a target, return a (freshly allocated with gpr_malloc) string |
| 66 | representing the default authority to pass from a client. */ |
| 67 | char *grpc_get_default_authority(const char *target); |
Craig Tiller | 3bc8ebd | 2015-06-24 15:41:15 -0700 | [diff] [blame] | 68 | |
Craig Tiller | 9a4dddd | 2016-03-25 17:08:13 -0700 | [diff] [blame] | 69 | #endif /* GRPC_CORE_LIB_CLIENT_CONFIG_RESOLVER_REGISTRY_H */ |