aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/surface/server.h
blob: 63b6dff16b8e11f6550514ed266ec04d1bebfb31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
 *
 * Copyright 2015 gRPC authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

#ifndef GRPC_CORE_LIB_SURFACE_SERVER_H
#define GRPC_CORE_LIB_SURFACE_SERVER_H

#include <grpc/grpc.h>
#include "src/core/lib/channel/channel_stack.h"
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/transport/transport.h"

extern const grpc_channel_filter grpc_server_top_filter;

/** Lightweight tracing of server channel state */
extern grpc_core::TraceFlag grpc_server_channel_trace;

/* Add a listener to the server: when the server starts, it will call start,
   and when it shuts down, it will call destroy */
void grpc_server_add_listener(grpc_server* server, void* listener,
                              void (*start)(grpc_server* server, void* arg,
                                            grpc_pollset** pollsets,
                                            size_t npollsets),
                              void (*destroy)(grpc_server* server, void* arg,
                                              grpc_closure* on_done));

/* Setup a transport - creates a channel stack, binds the transport to the
   server */
void grpc_server_setup_transport(grpc_server* server, grpc_transport* transport,
                                 grpc_pollset* accepting_pollset,
                                 const grpc_channel_args* args);

const grpc_channel_args* grpc_server_get_channel_args(grpc_server* server);

int grpc_server_has_open_connections(grpc_server* server);

/* Do not call this before grpc_server_start. Returns the pollsets and the
 * number of pollsets via 'pollsets' and 'pollset_count'. */
void grpc_server_get_pollsets(grpc_server* server, grpc_pollset*** pollsets,
                              size_t* pollset_count);

#endif /* GRPC_CORE_LIB_SURFACE_SERVER_H */