blob: 7f3d4a1cc039aeb2166fee320d0b0e1050bd7fdc [file] [log] [blame]
Craig Tiller91624662015-06-25 16:31:02 -07001/*
2 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02003 * Copyright 2015 gRPC authors.
Craig Tiller91624662015-06-25 16:31:02 -07004 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02005 * 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 Tiller91624662015-06-25 16:31:02 -07008 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02009 * http://www.apache.org/licenses/LICENSE-2.0
Craig Tiller91624662015-06-25 16:31:02 -070010 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +020011 * 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 Tiller91624662015-06-25 16:31:02 -070016 *
17 */
18
Craig Tillerd608cd62017-04-02 16:23:17 -070019#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_CONNECTOR_H
20#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_CONNECTOR_H
Craig Tiller91624662015-06-25 16:31:02 -070021
Craig Tiller9533d042016-03-25 17:11:06 -070022#include "src/core/lib/channel/channel_stack.h"
murgatroid997871f732016-09-23 13:49:05 -070023#include "src/core/lib/iomgr/resolve_address.h"
Craig Tiller9533d042016-03-25 17:11:06 -070024#include "src/core/lib/transport/transport.h"
Craig Tiller91624662015-06-25 16:31:02 -070025
26typedef struct grpc_connector grpc_connector;
27typedef struct grpc_connector_vtable grpc_connector_vtable;
28
Craig Tillera82950e2015-09-22 12:33:20 -070029struct grpc_connector {
Craig Tiller91624662015-06-25 16:31:02 -070030 const grpc_connector_vtable *vtable;
31};
32
Craig Tillera82950e2015-09-22 12:33:20 -070033typedef struct {
Craig Tiller04c5d4b2015-06-26 17:21:41 -070034 /** set of pollsets interested in this connection */
35 grpc_pollset_set *interested_parties;
Craig Tiller04c5d4b2015-06-26 17:21:41 -070036 /** deadline for connection */
37 gpr_timespec deadline;
38 /** channel arguments (to be passed to transport) */
39 const grpc_channel_args *channel_args;
Craig Tiller04c5d4b2015-06-26 17:21:41 -070040} grpc_connect_in_args;
41
Craig Tillera82950e2015-09-22 12:33:20 -070042typedef struct {
Craig Tiller04c5d4b2015-06-26 17:21:41 -070043 /** the connected transport */
44 grpc_transport *transport;
Julien Boeuf5b194032015-12-17 16:00:51 -080045
46 /** channel arguments (to be passed to the filters) */
Craig Tiller99b642a2016-06-01 17:20:34 -070047 grpc_channel_args *channel_args;
Craig Tiller04c5d4b2015-06-26 17:21:41 -070048} grpc_connect_out_args;
49
Craig Tillera82950e2015-09-22 12:33:20 -070050struct grpc_connector_vtable {
51 void (*ref)(grpc_connector *connector);
52 void (*unref)(grpc_exec_ctx *exec_ctx, grpc_connector *connector);
Craig Tiller131f6ed2015-09-15 08:20:20 -070053 /** Implementation of grpc_connector_shutdown */
Craig Tillercda759d2017-01-27 11:37:37 -080054 void (*shutdown)(grpc_exec_ctx *exec_ctx, grpc_connector *connector,
55 grpc_error *why);
Craig Tiller131f6ed2015-09-15 08:20:20 -070056 /** Implementation of grpc_connector_connect */
Craig Tillera82950e2015-09-22 12:33:20 -070057 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 Tiller91624662015-06-25 16:31:02 -070060};
61
Craig Tiller7391f132016-01-22 06:39:54 -080062grpc_connector *grpc_connector_ref(grpc_connector *connector);
Craig Tillera82950e2015-09-22 12:33:20 -070063void grpc_connector_unref(grpc_exec_ctx *exec_ctx, grpc_connector *connector);
Craig Tiller131f6ed2015-09-15 08:20:20 -070064/** Connect using the connector: max one outstanding call at a time */
Craig Tillera82950e2015-09-22 12:33:20 -070065void 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 Tiller131f6ed2015-09-15 08:20:20 -070069/** Cancel any pending connection */
Craig Tillercda759d2017-01-27 11:37:37 -080070void grpc_connector_shutdown(grpc_exec_ctx *exec_ctx, grpc_connector *connector,
71 grpc_error *why);
Craig Tiller91624662015-06-25 16:31:02 -070072
Craig Tillerd608cd62017-04-02 16:23:17 -070073#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_CONNECTOR_H */