3 * Copyright 2015 gRPC authors.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #ifndef GRPC_CORE_LIB_SURFACE_SERVER_H
20 #define GRPC_CORE_LIB_SURFACE_SERVER_H
22 #include <grpc/support/port_platform.h>
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"
30 extern const grpc_channel_filter grpc_server_top_filter;
32 /** Lightweight tracing of server channel state */
33 extern grpc_core::TraceFlag grpc_server_channel_trace;
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(
38 grpc_server* server, void* listener_arg,
39 void (*start)(grpc_server* server, void* arg, grpc_pollset** pollsets,
41 void (*destroy)(grpc_server* server, void* arg, grpc_closure* on_done),
42 grpc_core::RefCountedPtr<grpc_core::channelz::ListenSocketNode> node);
44 /* Setup a transport - creates a channel stack, binds the transport to the
46 void grpc_server_setup_transport(
47 grpc_server* server, grpc_transport* transport,
48 grpc_pollset* accepting_pollset, const grpc_channel_args* args,
49 const grpc_core::RefCountedPtr<grpc_core::channelz::SocketNode>&
51 grpc_resource_user* resource_user = nullptr);
53 grpc_core::channelz::ServerNode* grpc_server_get_channelz_node(
56 const grpc_channel_args* grpc_server_get_channel_args(grpc_server* server);
58 grpc_resource_user* grpc_server_get_default_resource_user(grpc_server* server);
60 int grpc_server_has_open_connections(grpc_server* server);
62 /* Do not call this before grpc_server_start. Returns the pollsets and the
63 * number of pollsets via 'pollsets' and 'pollset_count'. */
64 void grpc_server_get_pollsets(grpc_server* server, grpc_pollset*** pollsets,
65 size_t* pollset_count);
67 #endif /* GRPC_CORE_LIB_SURFACE_SERVER_H */