Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 1 | /* |
| 2 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 3 | * Copyright 2015 gRPC authors. |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [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 |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 8 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [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. |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 16 | * |
| 17 | */ |
| 18 | |
Craig Tiller | 9a4dddd | 2016-03-25 17:08:13 -0700 | [diff] [blame] | 19 | #ifndef GRPC_CORE_LIB_SURFACE_SERVER_H |
| 20 | #define GRPC_CORE_LIB_SURFACE_SERVER_H |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 21 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 22 | #include <grpc/grpc.h> |
Craig Tiller | 9533d04 | 2016-03-25 17:11:06 -0700 | [diff] [blame] | 23 | #include "src/core/lib/channel/channel_stack.h" |
Craig Tiller | 84f75d4 | 2017-05-03 13:06:35 -0700 | [diff] [blame] | 24 | #include "src/core/lib/debug/trace.h" |
Craig Tiller | 9533d04 | 2016-03-25 17:11:06 -0700 | [diff] [blame] | 25 | #include "src/core/lib/transport/transport.h" |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 26 | |
Yash Tibrewal | a7e6d65 | 2017-09-20 18:56:37 -0700 | [diff] [blame] | 27 | #ifdef __cplusplus |
| 28 | extern "C" { |
| 29 | #endif |
| 30 | |
Craig Tiller | 178edfa | 2016-02-17 20:54:46 -0800 | [diff] [blame] | 31 | extern const grpc_channel_filter grpc_server_top_filter; |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 32 | |
Craig Tiller | 687a0e6 | 2016-09-21 10:48:59 -0700 | [diff] [blame] | 33 | /** Lightweight tracing of server channel state */ |
Craig Tiller | 694580f | 2017-10-18 14:48:14 -0700 | [diff] [blame] | 34 | extern grpc_core::TraceFlag grpc_server_channel_trace; |
Craig Tiller | 687a0e6 | 2016-09-21 10:48:59 -0700 | [diff] [blame] | 35 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 36 | /* Add a listener to the server: when the server starts, it will call start, |
| 37 | and when it shuts down, it will call destroy */ |
Craig Tiller | a82950e | 2015-09-22 12:33:20 -0700 | [diff] [blame] | 38 | void grpc_server_add_listener( |
Craig Tiller | baa14a9 | 2017-11-03 09:09:36 -0700 | [diff] [blame] | 39 | grpc_exec_ctx* exec_ctx, grpc_server* server, void* listener, |
| 40 | void (*start)(grpc_exec_ctx* exec_ctx, grpc_server* server, void* arg, |
| 41 | grpc_pollset** pollsets, size_t npollsets), |
| 42 | void (*destroy)(grpc_exec_ctx* exec_ctx, grpc_server* server, void* arg, |
| 43 | grpc_closure* on_done)); |
Craig Tiller | aec96aa | 2015-04-07 14:32:15 -0700 | [diff] [blame] | 44 | |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 45 | /* Setup a transport - creates a channel stack, binds the transport to the |
| 46 | server */ |
Craig Tiller | baa14a9 | 2017-11-03 09:09:36 -0700 | [diff] [blame] | 47 | void grpc_server_setup_transport(grpc_exec_ctx* exec_ctx, grpc_server* server, |
| 48 | grpc_transport* transport, |
| 49 | grpc_pollset* accepting_pollset, |
| 50 | const grpc_channel_args* args); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 51 | |
Craig Tiller | baa14a9 | 2017-11-03 09:09:36 -0700 | [diff] [blame] | 52 | const grpc_channel_args* grpc_server_get_channel_args(grpc_server* server); |
Nicolas Noble | b7ebd3b | 2014-11-26 16:33:03 -0800 | [diff] [blame] | 53 | |
Craig Tiller | baa14a9 | 2017-11-03 09:09:36 -0700 | [diff] [blame] | 54 | int grpc_server_has_open_connections(grpc_server* server); |
Craig Tiller | ba3c3cd | 2015-05-26 06:28:10 -0700 | [diff] [blame] | 55 | |
Sree Kuchibhotla | cc357bf | 2016-08-22 16:08:50 -0700 | [diff] [blame] | 56 | /* Do not call this before grpc_server_start. Returns the pollsets and the |
| 57 | * number of pollsets via 'pollsets' and 'pollset_count'. */ |
Craig Tiller | baa14a9 | 2017-11-03 09:09:36 -0700 | [diff] [blame] | 58 | void grpc_server_get_pollsets(grpc_server* server, grpc_pollset*** pollsets, |
| 59 | size_t* pollset_count); |
Sree Kuchibhotla | cc357bf | 2016-08-22 16:08:50 -0700 | [diff] [blame] | 60 | |
Yash Tibrewal | a7e6d65 | 2017-09-20 18:56:37 -0700 | [diff] [blame] | 61 | #ifdef __cplusplus |
| 62 | } |
| 63 | #endif |
| 64 | |
Yash Tibrewal | 12fc6d4 | 2017-10-09 16:43:34 -0700 | [diff] [blame] | 65 | #endif /* GRPC_CORE_LIB_SURFACE_SERVER_H */ |