Classes | Public Member Functions | Protected Member Functions | Private Member Functions | Friends | List of all members
grpc::ServerInterface Class Referenceabstract

#include <server_interface.h>

Inheritance diagram for grpc::ServerInterface:
Inheritance graph
[legend]

Classes

class  BaseAsyncRequest
 
class  GenericAsyncRequest
 
class  NoPayloadAsyncRequest
 
class  PayloadAsyncRequest
 
class  RegisteredAsyncRequest
 RegisteredAsyncRequest is not part of the C++ API. More...
 

Public Member Functions

void Shutdown ()
 
template<class T >
void Shutdown (const T &deadline)
 
virtual void Wait ()=0
 
 ~ServerInterface () override
 
- Public Member Functions inherited from grpc::internal::CallHook
virtual ~CallHook ()
 

Protected Member Functions

virtual int AddListeningPort (const std::string &addr, ServerCredentials *creds)=0
 
virtual int max_receive_message_size () const =0
 
void PerformOpsOnCall (internal::CallOpSetInterface *ops, internal::Call *call) override=0
 
virtual void RegisterAsyncGenericService (AsyncGenericService *service)=0
 
virtual void RegisterCallbackGenericService (CallbackGenericService *)
 
virtual bool RegisterService (const std::string *host, Service *service)=0
 
void RequestAsyncCall (internal::RpcServiceMethod *method, grpc::ServerContext *context, internal::ServerAsyncStreamingInterface *stream, grpc::CompletionQueue *call_cq, grpc::ServerCompletionQueue *notification_cq, void *tag)
 
template<class Message >
void RequestAsyncCall (internal::RpcServiceMethod *method, grpc::ServerContext *context, internal::ServerAsyncStreamingInterface *stream, grpc::CompletionQueue *call_cq, grpc::ServerCompletionQueue *notification_cq, void *tag, Message *message)
 
void RequestAsyncGenericCall (GenericServerContext *context, internal::ServerAsyncStreamingInterface *stream, grpc::CompletionQueue *call_cq, grpc::ServerCompletionQueue *notification_cq, void *tag)
 
virtual grpc_serverserver ()=0
 
virtual void ShutdownInternal (gpr_timespec deadline)=0
 
virtual void Start (grpc::ServerCompletionQueue **cqs, size_t num_cqs)=0
 

Private Member Functions

virtual grpc::CompletionQueueCallbackCQ ()
 
virtual std::vector< std::unique_ptr< experimental::ServerInterceptorFactoryInterface > > * interceptor_creators ()
 

Friends

class grpc::Service
 

Detailed Description

Definition at line 61 of file grpcpp/impl/codegen/server_interface.h.

Constructor & Destructor Documentation

◆ ~ServerInterface()

grpc::ServerInterface::~ServerInterface ( )
inlineoverride

Definition at line 63 of file grpcpp/impl/codegen/server_interface.h.

Member Function Documentation

◆ AddListeningPort()

virtual int grpc::ServerInterface::AddListeningPort ( const std::string &  addr,
ServerCredentials creds 
)
protectedpure virtual

Tries to bind server to the given addr.

It can be invoked multiple times.

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

Implemented in grpc::Server.

◆ CallbackCQ()

virtual grpc::CompletionQueue* grpc::ServerInterface::CallbackCQ ( )
inlineprivatevirtual

Reimplemented in grpc::Server.

Definition at line 365 of file grpcpp/impl/codegen/server_interface.h.

◆ interceptor_creators()

virtual std::vector< std::unique_ptr<experimental::ServerInterceptorFactoryInterface> >* grpc::ServerInterface::interceptor_creators ( )
inlineprivatevirtual

Reimplemented in grpc::Server.

Definition at line 354 of file grpcpp/impl/codegen/server_interface.h.

◆ max_receive_message_size()

virtual int grpc::ServerInterface::max_receive_message_size ( ) const
protectedpure virtual

Implemented in grpc::Server.

◆ PerformOpsOnCall()

void grpc::ServerInterface::PerformOpsOnCall ( internal::CallOpSetInterface ops,
internal::Call call 
)
overrideprotectedpure virtual

Implements grpc::internal::CallHook.

Implemented in grpc::Server.

◆ RegisterAsyncGenericService()

virtual void grpc::ServerInterface::RegisterAsyncGenericService ( AsyncGenericService service)
protectedpure virtual

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

Implemented in grpc::Server.

◆ RegisterCallbackGenericService()

virtual void grpc::ServerInterface::RegisterCallbackGenericService ( CallbackGenericService )
inlineprotectedvirtual

Register a callback generic service. This call does not take ownership of the service. The service must exist for the lifetime of the Server instance. May not be abstract since this is a post-1.0 API addition.

Reimplemented in grpc::Server.

Definition at line 133 of file grpcpp/impl/codegen/server_interface.h.

◆ RegisterService()

virtual bool grpc::ServerInterface::RegisterService ( const std::string *  host,
Service service 
)
protectedpure virtual

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

Implemented in grpc::Server.

◆ RequestAsyncCall() [1/2]

void grpc::ServerInterface::RequestAsyncCall ( internal::RpcServiceMethod method,
grpc::ServerContext context,
internal::ServerAsyncStreamingInterface stream,
grpc::CompletionQueue call_cq,
grpc::ServerCompletionQueue notification_cq,
void *  tag 
)
inlineprotected

Definition at line 326 of file grpcpp/impl/codegen/server_interface.h.

◆ RequestAsyncCall() [2/2]

template<class Message >
void grpc::ServerInterface::RequestAsyncCall ( internal::RpcServiceMethod method,
grpc::ServerContext context,
internal::ServerAsyncStreamingInterface stream,
grpc::CompletionQueue call_cq,
grpc::ServerCompletionQueue notification_cq,
void *  tag,
Message message 
)
inlineprotected

Definition at line 315 of file grpcpp/impl/codegen/server_interface.h.

◆ RequestAsyncGenericCall()

void grpc::ServerInterface::RequestAsyncGenericCall ( GenericServerContext context,
internal::ServerAsyncStreamingInterface stream,
grpc::CompletionQueue call_cq,
grpc::ServerCompletionQueue notification_cq,
void *  tag 
)
inlineprotected

Definition at line 337 of file grpcpp/impl/codegen/server_interface.h.

◆ server()

virtual grpc_server* grpc::ServerInterface::server ( )
protectedpure virtual

Implemented in grpc::Server.

◆ Shutdown() [1/2]

void grpc::ServerInterface::Shutdown ( )
inline

Shutdown the server without a deadline and forced cancellation.

All completion queue associated with the server (for example, for async serving) must be shutdown after this method has returned: See ServerBuilder::AddCompletionQueue for details.

Definition at line 107 of file grpcpp/impl/codegen/server_interface.h.

◆ Shutdown() [2/2]

template<class T >
void grpc::ServerInterface::Shutdown ( const T deadline)
inline

Shutdown does the following things:

  1. Shutdown the server: deactivate all listening ports, mark it in "shutdown mode" so that further call Request's or incoming RPC matches are no longer allowed. Also return all Request'ed-but-not-yet-active calls as failed (!ok). This refers to calls that have been requested at the server by the server-side library or application code but that have not yet been matched to incoming RPCs from the client. Note that this would even include default calls added automatically by the gRPC C++ API without the user's input (e.g., "Unimplemented RPC method")
  2. Block until all rpc method handlers invoked automatically by the sync API finish.
  3. If all pending calls complete (and all their operations are retrieved by Next) before deadline expires, this finishes gracefully. Otherwise, forcefully cancel all pending calls associated with the server after deadline expires. In the case of the sync API, if the RPC function for a streaming call has already been started and takes a week to complete, the RPC function won't be forcefully terminated (since that would leave state corrupt and incomplete) and the method handler will just keep running (which will prevent the server from completing the "join" operation that it needs to do at shutdown time).

All completion queue associated with the server (for example, for async serving) must be shutdown after this method has returned: See ServerBuilder::AddCompletionQueue for details. They must also be drained (by repeated Next) after being shutdown.

Parameters
deadlineHow long to wait until pending rpcs are forcefully terminated.

Definition at line 98 of file grpcpp/impl/codegen/server_interface.h.

◆ ShutdownInternal()

virtual void grpc::ServerInterface::ShutdownInternal ( gpr_timespec  deadline)
protectedpure virtual

Implemented in grpc::Server.

◆ Start()

virtual void grpc::ServerInterface::Start ( grpc::ServerCompletionQueue **  cqs,
size_t  num_cqs 
)
protectedpure virtual

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.

Implemented in grpc::Server.

◆ Wait()

virtual void grpc::ServerInterface::Wait ( )
pure virtual

Block waiting for all work to complete.

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

Implemented in grpc::Server.

Friends And Related Function Documentation

◆ grpc::Service

friend class grpc::Service
friend

Definition at line 119 of file grpcpp/impl/codegen/server_interface.h.


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


grpc
Author(s):
autogenerated on Fri May 16 2025 03:03:31