blob: 23040c3e234eb0712c8a067165c71177f982de77 [file] [log] [blame]
Craig Tiller91624662015-06-25 16:31:02 -07001/*
2 *
Craig Tiller6169d5f2016-03-31 07:46:18 -07003 * Copyright 2015, Google Inc.
Craig Tiller91624662015-06-25 16:31:02 -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
Craig Tillerd608cd62017-04-02 16:23:17 -070034#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_CONNECTOR_H
35#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_CONNECTOR_H
Craig Tiller91624662015-06-25 16:31:02 -070036
Craig Tiller9533d042016-03-25 17:11:06 -070037#include "src/core/lib/channel/channel_stack.h"
murgatroid997871f732016-09-23 13:49:05 -070038#include "src/core/lib/iomgr/resolve_address.h"
Craig Tiller9533d042016-03-25 17:11:06 -070039#include "src/core/lib/transport/transport.h"
Craig Tiller91624662015-06-25 16:31:02 -070040
41typedef struct grpc_connector grpc_connector;
42typedef struct grpc_connector_vtable grpc_connector_vtable;
43
Craig Tillera82950e2015-09-22 12:33:20 -070044struct grpc_connector {
Craig Tiller91624662015-06-25 16:31:02 -070045 const grpc_connector_vtable *vtable;
46};
47
Craig Tillera82950e2015-09-22 12:33:20 -070048typedef struct {
Craig Tiller04c5d4b2015-06-26 17:21:41 -070049 /** set of pollsets interested in this connection */
50 grpc_pollset_set *interested_parties;
Craig Tiller04c5d4b2015-06-26 17:21:41 -070051 /** deadline for connection */
52 gpr_timespec deadline;
53 /** channel arguments (to be passed to transport) */
54 const grpc_channel_args *channel_args;
Craig Tiller04c5d4b2015-06-26 17:21:41 -070055} grpc_connect_in_args;
56
Craig Tillera82950e2015-09-22 12:33:20 -070057typedef struct {
Craig Tiller04c5d4b2015-06-26 17:21:41 -070058 /** the connected transport */
59 grpc_transport *transport;
Julien Boeuf5b194032015-12-17 16:00:51 -080060
61 /** channel arguments (to be passed to the filters) */
Craig Tiller99b642a2016-06-01 17:20:34 -070062 grpc_channel_args *channel_args;
Craig Tiller04c5d4b2015-06-26 17:21:41 -070063} grpc_connect_out_args;
64
Craig Tillera82950e2015-09-22 12:33:20 -070065struct grpc_connector_vtable {
66 void (*ref)(grpc_connector *connector);
67 void (*unref)(grpc_exec_ctx *exec_ctx, grpc_connector *connector);
Craig Tiller131f6ed2015-09-15 08:20:20 -070068 /** Implementation of grpc_connector_shutdown */
Craig Tillercda759d2017-01-27 11:37:37 -080069 void (*shutdown)(grpc_exec_ctx *exec_ctx, grpc_connector *connector,
70 grpc_error *why);
Craig Tiller131f6ed2015-09-15 08:20:20 -070071 /** Implementation of grpc_connector_connect */
Craig Tillera82950e2015-09-22 12:33:20 -070072 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 Tiller91624662015-06-25 16:31:02 -070075};
76
Craig Tiller7391f132016-01-22 06:39:54 -080077grpc_connector *grpc_connector_ref(grpc_connector *connector);
Craig Tillera82950e2015-09-22 12:33:20 -070078void grpc_connector_unref(grpc_exec_ctx *exec_ctx, grpc_connector *connector);
Craig Tiller131f6ed2015-09-15 08:20:20 -070079/** Connect using the connector: max one outstanding call at a time */
Craig Tillera82950e2015-09-22 12:33:20 -070080void 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 Tiller131f6ed2015-09-15 08:20:20 -070084/** Cancel any pending connection */
Craig Tillercda759d2017-01-27 11:37:37 -080085void grpc_connector_shutdown(grpc_exec_ctx *exec_ctx, grpc_connector *connector,
86 grpc_error *why);
Craig Tiller91624662015-06-25 16:31:02 -070087
Craig Tillerd608cd62017-04-02 16:23:17 -070088#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_CONNECTOR_H */