• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *
3  * Copyright 2015 gRPC authors.
4  *
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
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  *
17  */
18 
19 #ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_CONNECTOR_H
20 #define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_CONNECTOR_H
21 
22 #include <grpc/support/port_platform.h>
23 
24 #include "src/core/lib/channel/channel_stack.h"
25 #include "src/core/lib/iomgr/resolve_address.h"
26 #include "src/core/lib/transport/transport.h"
27 
28 typedef struct grpc_connector grpc_connector;
29 typedef struct grpc_connector_vtable grpc_connector_vtable;
30 
31 struct grpc_connector {
32   const grpc_connector_vtable* vtable;
33 };
34 
35 typedef struct {
36   /** set of pollsets interested in this connection */
37   grpc_pollset_set* interested_parties;
38   /** deadline for connection */
39   grpc_millis deadline;
40   /** channel arguments (to be passed to transport) */
41   const grpc_channel_args* channel_args;
42 } grpc_connect_in_args;
43 
44 typedef struct {
45   /** the connected transport */
46   grpc_transport* transport;
47 
48   /** channel arguments (to be passed to the filters) */
49   grpc_channel_args* channel_args;
50 } grpc_connect_out_args;
51 
52 struct grpc_connector_vtable {
53   void (*ref)(grpc_connector* connector);
54   void (*unref)(grpc_connector* connector);
55   /** Implementation of grpc_connector_shutdown */
56   void (*shutdown)(grpc_connector* connector, grpc_error* why);
57   /** Implementation of grpc_connector_connect */
58   void (*connect)(grpc_connector* connector,
59                   const grpc_connect_in_args* in_args,
60                   grpc_connect_out_args* out_args, grpc_closure* notify);
61 };
62 
63 grpc_connector* grpc_connector_ref(grpc_connector* connector);
64 void grpc_connector_unref(grpc_connector* connector);
65 /** Connect using the connector: max one outstanding call at a time */
66 void grpc_connector_connect(grpc_connector* connector,
67                             const grpc_connect_in_args* in_args,
68                             grpc_connect_out_args* out_args,
69                             grpc_closure* notify);
70 /** Cancel any pending connection */
71 void grpc_connector_shutdown(grpc_connector* connector, grpc_error* why);
72 
73 #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_CONNECTOR_H */
74