GRPC C++  1.30.0
Data Structures | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends
grpc_impl::Server Class Reference

Represents a gRPC server. More...

#include <server_impl.h>

Data Structures

class  experimental_type
 NOTE: class experimental_type is not part of the public API of this class. More...
 
class  GlobalCallbacks
 Global callbacks are a set of hooks that are called when server events occur. More...
 

Public Member Functions

 ~Server ()
 
void Wait () override
 Block until the server shuts down. More...
 
grpc_serverc_server ()
 Returns a raw pointer to the underlying grpc_server instance. More...
 
grpc::HealthCheckServiceInterfaceGetHealthCheckService () const
 Returns the health check service. More...
 
std::shared_ptr< ChannelInProcessChannel (const ChannelArguments &args)
 Establish a channel for in-process communication. More...
 
experimental_type experimental ()
 NOTE: The function experimental() is not stable public API. More...
 
- Public Member Functions inherited from grpc::ServerInterface
virtual ~ServerInterface ()
 
template<class T >
void Shutdown (const T &deadline)
 Shutdown does the following things: More...
 
void Shutdown ()
 Shutdown the server without a deadline and forced cancellation. More...
 
- Public Member Functions inherited from grpc::internal::CallHook
virtual ~CallHook ()
 

Static Public Member Functions

static void SetGlobalCallbacks (GlobalCallbacks *callbacks)
 Set the global callback object. More...
 

Protected Member Functions

bool RegisterService (const grpc::string *host, grpc::Service *service) override
 Register a service. More...
 
int AddListeningPort (const grpc::string &addr, grpc::ServerCredentials *creds) override
 Try binding the server to the given addr endpoint (port, and optionally including IP address to bind to). More...
 
 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< grpc::internal::ExternalConnectionAcceptorImpl >> acceptors, grpc_resource_quota *server_rq=nullptr, std::vector< std::unique_ptr< grpc::experimental::ServerInterceptorFactoryInterface >> interceptor_creators=std::vector< std::unique_ptr< grpc::experimental::ServerInterceptorFactoryInterface >>())
 NOTE: This is NOT a public API. More...
 
void Start (ServerCompletionQueue **cqs, size_t num_cqs) override
 Start the server. More...
 
grpc_serverserver () override
 
void set_health_check_service (std::unique_ptr< grpc::HealthCheckServiceInterface > service)
 NOTE: This method is not part of the public API for this class. More...
 
bool health_check_service_disabled () const
 NOTE: This method is not part of the public API for this class. More...
 
- Protected Member Functions inherited from grpc::ServerInterface
virtual void Start (::grpc_impl::ServerCompletionQueue **cqs, size_t num_cqs)=0
 Start the server. More...
 
template<class Message >
void RequestAsyncCall (internal::RpcServiceMethod *method, ::grpc_impl::ServerContext *context, internal::ServerAsyncStreamingInterface *stream, ::grpc_impl::CompletionQueue *call_cq, ::grpc_impl::ServerCompletionQueue *notification_cq, void *tag, Message *message)
 
void RequestAsyncCall (internal::RpcServiceMethod *method, ::grpc_impl::ServerContext *context, internal::ServerAsyncStreamingInterface *stream, ::grpc_impl::CompletionQueue *call_cq, ::grpc_impl::ServerCompletionQueue *notification_cq, void *tag)
 
void RequestAsyncGenericCall (GenericServerContext *context, internal::ServerAsyncStreamingInterface *stream, ::grpc_impl::CompletionQueue *call_cq, ::grpc_impl::ServerCompletionQueue *notification_cq, void *tag)
 

Friends

class grpc::AsyncGenericService
 
class grpc_impl::ServerBuilder
 
class grpc_impl::ServerInitializer
 

Detailed Description

Represents a gRPC server.

Use a grpc::ServerBuilder to create, configure, and start Server instances.

Constructor & Destructor Documentation

◆ ~Server()

grpc_impl::Server::~Server ( )

◆ Server()

grpc_impl::Server::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< grpc::internal::ExternalConnectionAcceptorImpl >>  acceptors,
grpc_resource_quota server_rq = nullptr,
std::vector< std::unique_ptr< grpc::experimental::ServerInterceptorFactoryInterface >>  interceptor_creators = std::vector< std::unique_ptr< grpc::experimental::ServerInterceptorFactoryInterface >>() 
)
protected

NOTE: This is NOT a public API.

The server constructors are supposed to be used by ServerBuilder class only. The constructor will be made 'private' very soon.

Server constructors. To be used by ServerBuilder only.

Parameters
argsThe channel args
sync_server_cqsThe 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_pollersThe 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_pollersThe 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_msecThe timeout to use when calling AsyncNext() on server completion queues passed via sync_server_cqs param.

Member Function Documentation

◆ AddListeningPort()

int grpc_impl::Server::AddListeningPort ( const grpc::string addr,
grpc::ServerCredentials creds 
)
overrideprotectedvirtual

Try binding the server to the given addr endpoint (port, and optionally including IP address to bind to).

It can be invoked multiple times. Should be used before starting the server.

Parameters
addrThe address to try to bind to the server (eg, localhost:1234, 192.168.1.1:31416, [::1]:27182, etc.).
credsThe credentials associated with the server.
Returns
bound port number on success, 0 on failure.
Warning
It is an error to call this method on an already started server.

Implements grpc::ServerInterface.

◆ c_server()

grpc_server* grpc_impl::Server::c_server ( )

Returns a raw pointer to the underlying grpc_server instance.

EXPERIMENTAL: for internal/test use only

◆ experimental()

experimental_type grpc_impl::Server::experimental ( )
inline

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.

◆ GetHealthCheckService()

grpc::HealthCheckServiceInterface* grpc_impl::Server::GetHealthCheckService ( ) const
inline

Returns the health check service.

◆ health_check_service_disabled()

bool grpc_impl::Server::health_check_service_disabled ( ) const
inlineprotected

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

◆ InProcessChannel()

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

Establish a channel for in-process communication.

◆ RegisterService()

bool grpc_impl::Server::RegisterService ( const grpc::string host,
grpc::Service service 
)
overrideprotectedvirtual

Register a service.

This call does not take ownership of the service. The service must exist for the lifetime of the Server instance.

Implements grpc::ServerInterface.

◆ server()

grpc_server* grpc_impl::Server::server ( )
inlineoverrideprotectedvirtual

Implements grpc::ServerInterface.

◆ set_health_check_service()

void grpc_impl::Server::set_health_check_service ( std::unique_ptr< grpc::HealthCheckServiceInterface service)
inlineprotected

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

◆ SetGlobalCallbacks()

static void grpc_impl::Server::SetGlobalCallbacks ( GlobalCallbacks callbacks)
static

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 GlobalCallbacks object will be used throughout the application and is shared among all Server objects.

◆ Start()

void grpc_impl::Server::Start ( ServerCompletionQueue **  cqs,
size_t  num_cqs 
)
overrideprotected

Start the server.

Parameters
cqsCompletion queues for handling asynchronous services. The caller is required to keep all completion queues live until the server is destroyed.
num_cqsHow many completion queues does cqs hold.

◆ Wait()

void grpc_impl::Server::Wait ( )
overridevirtual

Block until the server shuts down.

Warning
The server must be either shutting down or some other thread must call Shutdown for this function to ever return.

Implements grpc::ServerInterface.

Friends And Related Function Documentation

◆ grpc::AsyncGenericService

friend class grpc::AsyncGenericService
friend

◆ grpc_impl::ServerBuilder

friend class grpc_impl::ServerBuilder
friend

◆ grpc_impl::ServerInitializer

friend class grpc_impl::ServerInitializer
friend

The documentation for this class was generated from the following file: