blob: d5c2b0f2be53b2ba0bf153789b3b081c4ba10886 [file] [log] [blame]
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08001/*
2 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02003 * Copyright 2015 gRPC authors.
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08004 *
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
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -08008 *
Jan Tattermusch7897ae92017-06-07 22:57:36 +02009 * http://www.apache.org/licenses/LICENSE-2.0
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080010 *
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.
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080016 *
17 */
18
Craig Tiller9a4dddd2016-03-25 17:08:13 -070019#ifndef GRPC_CORE_LIB_SURFACE_SERVER_H
20#define GRPC_CORE_LIB_SURFACE_SERVER_H
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080021
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080022#include <grpc/grpc.h>
Craig Tiller9533d042016-03-25 17:11:06 -070023#include "src/core/lib/channel/channel_stack.h"
Craig Tiller84f75d42017-05-03 13:06:35 -070024#include "src/core/lib/debug/trace.h"
Craig Tiller9533d042016-03-25 17:11:06 -070025#include "src/core/lib/transport/transport.h"
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080026
Yash Tibrewala7e6d652017-09-20 18:56:37 -070027#ifdef __cplusplus
28extern "C" {
29#endif
30
Craig Tiller178edfa2016-02-17 20:54:46 -080031extern const grpc_channel_filter grpc_server_top_filter;
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080032
Craig Tiller687a0e62016-09-21 10:48:59 -070033/** Lightweight tracing of server channel state */
Craig Tiller694580f2017-10-18 14:48:14 -070034extern grpc_core::TraceFlag grpc_server_channel_trace;
Craig Tiller687a0e62016-09-21 10:48:59 -070035
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080036/* 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 Tillera82950e2015-09-22 12:33:20 -070038void grpc_server_add_listener(
Craig Tillerbaa14a92017-11-03 09:09:36 -070039 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 Tilleraec96aa2015-04-07 14:32:15 -070044
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080045/* Setup a transport - creates a channel stack, binds the transport to the
46 server */
Craig Tillerbaa14a92017-11-03 09:09:36 -070047void 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 Nobleb7ebd3b2014-11-26 16:33:03 -080051
Craig Tillerbaa14a92017-11-03 09:09:36 -070052const grpc_channel_args* grpc_server_get_channel_args(grpc_server* server);
Nicolas Nobleb7ebd3b2014-11-26 16:33:03 -080053
Craig Tillerbaa14a92017-11-03 09:09:36 -070054int grpc_server_has_open_connections(grpc_server* server);
Craig Tillerba3c3cd2015-05-26 06:28:10 -070055
Sree Kuchibhotlacc357bf2016-08-22 16:08:50 -070056/* Do not call this before grpc_server_start. Returns the pollsets and the
57 * number of pollsets via 'pollsets' and 'pollset_count'. */
Craig Tillerbaa14a92017-11-03 09:09:36 -070058void grpc_server_get_pollsets(grpc_server* server, grpc_pollset*** pollsets,
59 size_t* pollset_count);
Sree Kuchibhotlacc357bf2016-08-22 16:08:50 -070060
Yash Tibrewala7e6d652017-09-20 18:56:37 -070061#ifdef __cplusplus
62}
63#endif
64
Yash Tibrewal12fc6d42017-10-09 16:43:34 -070065#endif /* GRPC_CORE_LIB_SURFACE_SERVER_H */