class Server

Defined at line 57 of file ../../third_party/grpc-migrating/src/include/grpcpp/server.h

Represents a gRPC server.

Use a

to create, configure, and start

instances.

Public Methods

HealthCheckServiceInterface * GetHealthCheckService ()

Returns the health check service.

Defined at line 100 of file ../../third_party/grpc-migrating/src/include/grpcpp/server.h

void ~Server ()
void Wait ()

Block until the server shuts down.

void SetGlobalCallbacks (GlobalCallbacks * callbacks)

Set the global callback object. Can only be called once per application.

Does not take ownership of callbacks, and expects the pointed to object

to be alive until all server objects in the process have been destroyed.

The same

object will be used throughout the

application and is shared among all

objects.

grpc_server * c_server ()

Returns a

pointer to the underlying

instance.

EXPERIMENTAL: for internal/test use only

std::shared_ptr<Channel> InProcessChannel (const ChannelArguments & args)

Establish a channel for in-process communication

experimental_type experimental ()

NOTE: The function experimental() is not stable public API. It is a view

to the experimental components of this class. It may be changed or removed

at any time.

Defined at line 129 of file ../../third_party/grpc-migrating/src/include/grpcpp/server.h

Protected Methods

bool RegisterService (const std::string * addr, Service * service)

Register a service. This call does not take ownership of the service.

The service must exist for the lifetime of the Server instance.

int AddListeningPort (const std::string & addr, ServerCredentials * creds)

Try binding the server to the given

endpoint

(port, and optionally including IP address to bind to).

It can be invoked multiple times. Should be used before

starting the server.

Parameters

addr The address to try to bind to the server (eg, localhost:1234, 192.168.1.1:31416, [::1]:27182, etc.).
creds The credentials associated with the server.

Returns

bound port number on success, 0 on failure.

void Server (ChannelArguments * args, std::shared_ptr<std::vector<std::unique_ptr<ServerCompletionQueue>>> sync_server_cqs, int min_pollers, int max_pollers, int sync_cq_timeout_msec, std::vector<std::shared_ptr<internal::ExternalConnectionAcceptorImpl>> acceptors, grpc_server_config_fetcher * server_config_fetcher, grpc_resource_quota * server_rq, std::vector<std::unique_ptr<experimental::ServerInterceptorFactoryInterface>> interceptor_creators, experimental::ServerMetricRecorder * server_metric_recorder)

NOTE: This is *NOT* a public API. The server constructors are supposed to

be used by

class only. The constructor will be made

'private' very soon.

Server constructors. To be used by

only.

Parameters

args The channel args
sync_server_cqs The completion queues to use if the server is a synchronous server (or a hybrid server). The server polls for new RPCs on these queues
min_pollers The minimum number of polling threads per server completion queue (in param sync_server_cqs) to use for listening to incoming requests (used only in case of sync server)
max_pollers The maximum number of polling threads per server completion queue (in param sync_server_cqs) to use for listening to incoming requests (used only in case of sync server)
sync_cq_timeout_msec The timeout to use when calling AsyncNext() on server completion queues passed via sync_server_cqs param.
void Start (ServerCompletionQueue ** cqs, size_t num_cqs)

Start the server.

Parameters

cqs Completion queues for handling asynchronous services. The caller is required to keep all completion queues live until the server is destroyed.
num_cqs How many completion queues does hold.
grpc_server * server ()

Defined at line 196 of file ../../third_party/grpc-migrating/src/include/grpcpp/server.h

void set_health_check_service (std::unique_ptr<HealthCheckServiceInterface> service)

NOTE: This method is not part of the public API for this class.

Defined at line 199 of file ../../third_party/grpc-migrating/src/include/grpcpp/server.h

ContextAllocator * context_allocator ()

Defined at line 204 of file ../../third_party/grpc-migrating/src/include/grpcpp/server.h

bool health_check_service_disabled ()

NOTE: This method is not part of the public API for this class.

Defined at line 207 of file ../../third_party/grpc-migrating/src/include/grpcpp/server.h

Records

Friends

class ServerInitializer
class ServerBuilder
class AsyncGenericService