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