Craig Tiller | 9162466 | 2015-06-25 16:31:02 -0700 | [diff] [blame] | 1 | /* |
| 2 | * |
Craig Tiller | 6169d5f | 2016-03-31 07:46:18 -0700 | [diff] [blame] | 3 | * Copyright 2015, Google Inc. |
Craig Tiller | 9162466 | 2015-06-25 16:31:02 -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 | d608cd6 | 2017-04-02 16:23:17 -0700 | [diff] [blame] | 34 | #ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_CONNECTOR_H |
| 35 | #define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_CONNECTOR_H |
Craig Tiller | 9162466 | 2015-06-25 16:31:02 -0700 | [diff] [blame] | 36 | |
Craig Tiller | 9533d04 | 2016-03-25 17:11:06 -0700 | [diff] [blame] | 37 | #include "src/core/lib/channel/channel_stack.h" |
murgatroid99 | 7871f73 | 2016-09-23 13:49:05 -0700 | [diff] [blame] | 38 | #include "src/core/lib/iomgr/resolve_address.h" |
Craig Tiller | 9533d04 | 2016-03-25 17:11:06 -0700 | [diff] [blame] | 39 | #include "src/core/lib/transport/transport.h" |
Craig Tiller | 9162466 | 2015-06-25 16:31:02 -0700 | [diff] [blame] | 40 | |
| 41 | typedef struct grpc_connector grpc_connector; |
| 42 | typedef struct grpc_connector_vtable grpc_connector_vtable; |
| 43 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 44 | struct grpc_connector { |
Craig Tiller | 9162466 | 2015-06-25 16:31:02 -0700 | [diff] [blame] | 45 | const grpc_connector_vtable *vtable; |
| 46 | }; |
| 47 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 48 | typedef struct { |
Craig Tiller | 04c5d4b | 2015-06-26 17:21:41 -0700 | [diff] [blame] | 49 | /** set of pollsets interested in this connection */ |
| 50 | grpc_pollset_set *interested_parties; |
Craig Tiller | 04c5d4b | 2015-06-26 17:21:41 -0700 | [diff] [blame] | 51 | /** deadline for connection */ |
| 52 | gpr_timespec deadline; |
| 53 | /** channel arguments (to be passed to transport) */ |
| 54 | const grpc_channel_args *channel_args; |
Craig Tiller | 04c5d4b | 2015-06-26 17:21:41 -0700 | [diff] [blame] | 55 | } grpc_connect_in_args; |
| 56 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 57 | typedef struct { |
Craig Tiller | 04c5d4b | 2015-06-26 17:21:41 -0700 | [diff] [blame] | 58 | /** the connected transport */ |
| 59 | grpc_transport *transport; |
Julien Boeuf | 5b19403 | 2015-12-17 16:00:51 -0800 | [diff] [blame] | 60 | |
| 61 | /** channel arguments (to be passed to the filters) */ |
Craig Tiller | 99b642a | 2016-06-01 17:20:34 -0700 | [diff] [blame] | 62 | grpc_channel_args *channel_args; |
Craig Tiller | 04c5d4b | 2015-06-26 17:21:41 -0700 | [diff] [blame] | 63 | } grpc_connect_out_args; |
| 64 | |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 65 | struct grpc_connector_vtable { |
| 66 | void (*ref)(grpc_connector *connector); |
| 67 | void (*unref)(grpc_exec_ctx *exec_ctx, grpc_connector *connector); |
Craig Tiller | 131f6ed | 2015-09-15 08:20:20 -0700 | [diff] [blame] | 68 | /** Implementation of grpc_connector_shutdown */ |
Craig Tiller | cda759d | 2017-01-27 11:37:37 -0800 | [diff] [blame] | 69 | void (*shutdown)(grpc_exec_ctx *exec_ctx, grpc_connector *connector, |
| 70 | grpc_error *why); |
Craig Tiller | 131f6ed | 2015-09-15 08:20:20 -0700 | [diff] [blame] | 71 | /** Implementation of grpc_connector_connect */ |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 72 | void (*connect)(grpc_exec_ctx *exec_ctx, grpc_connector *connector, |
| 73 | const grpc_connect_in_args *in_args, |
| 74 | grpc_connect_out_args *out_args, grpc_closure *notify); |
Craig Tiller | 9162466 | 2015-06-25 16:31:02 -0700 | [diff] [blame] | 75 | }; |
| 76 | |
Craig Tiller | 7391f13 | 2016-01-22 06:39:54 -0800 | [diff] [blame] | 77 | grpc_connector *grpc_connector_ref(grpc_connector *connector); |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 78 | void grpc_connector_unref(grpc_exec_ctx *exec_ctx, grpc_connector *connector); |
Craig Tiller | 131f6ed | 2015-09-15 08:20:20 -0700 | [diff] [blame] | 79 | /** Connect using the connector: max one outstanding call at a time */ |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 80 | void grpc_connector_connect(grpc_exec_ctx *exec_ctx, grpc_connector *connector, |
| 81 | const grpc_connect_in_args *in_args, |
| 82 | grpc_connect_out_args *out_args, |
| 83 | grpc_closure *notify); |
Craig Tiller | 131f6ed | 2015-09-15 08:20:20 -0700 | [diff] [blame] | 84 | /** Cancel any pending connection */ |
Craig Tiller | cda759d | 2017-01-27 11:37:37 -0800 | [diff] [blame] | 85 | void grpc_connector_shutdown(grpc_exec_ctx *exec_ctx, grpc_connector *connector, |
| 86 | grpc_error *why); |
Craig Tiller | 9162466 | 2015-06-25 16:31:02 -0700 | [diff] [blame] | 87 | |
Craig Tiller | d608cd6 | 2017-04-02 16:23:17 -0700 | [diff] [blame] | 88 | #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_CONNECTOR_H */ |