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_LIB_SURFACE_SERVER_H 20 #define GRPC_CORE_LIB_SURFACE_SERVER_H 21 22 #include <grpc/support/port_platform.h> 23 24 #include <grpc/grpc.h> 25 #include "src/core/lib/channel/channel_stack.h" 26 #include "src/core/lib/channel/channelz.h" 27 #include "src/core/lib/debug/trace.h" 28 #include "src/core/lib/transport/transport.h" 29 30 extern const grpc_channel_filter grpc_server_top_filter; 31 32 /** Lightweight tracing of server channel state */ 33 extern grpc_core::TraceFlag grpc_server_channel_trace; 34 35 /* Add a listener to the server: when the server starts, it will call start, 36 and when it shuts down, it will call destroy */ 37 void grpc_server_add_listener(grpc_server* server, void* listener, 38 void (*start)(grpc_server* server, void* arg, 39 grpc_pollset** pollsets, 40 size_t npollsets), 41 void (*destroy)(grpc_server* server, void* arg, 42 grpc_closure* on_done)); 43 44 /* Setup a transport - creates a channel stack, binds the transport to the 45 server */ 46 void grpc_server_setup_transport(grpc_server* server, grpc_transport* transport, 47 grpc_pollset* accepting_pollset, 48 const grpc_channel_args* args); 49 50 grpc_core::channelz::ServerNode* grpc_server_get_channelz_node( 51 grpc_server* server); 52 53 const grpc_channel_args* grpc_server_get_channel_args(grpc_server* server); 54 55 int grpc_server_has_open_connections(grpc_server* server); 56 57 /* Do not call this before grpc_server_start. Returns the pollsets and the 58 * number of pollsets via 'pollsets' and 'pollset_count'. */ 59 void grpc_server_get_pollsets(grpc_server* server, grpc_pollset*** pollsets, 60 size_t* pollset_count); 61 62 #endif /* GRPC_CORE_LIB_SURFACE_SERVER_H */ 63