19 #ifndef GRPCPP_SERVER_H 20 #define GRPCPP_SERVER_H 22 #include <condition_variable> 45 class AsyncGenericService;
46 class HealthCheckServiceInterface;
48 class ServerInitializer;
98 return health_check_service_.get();
113 std::shared_ptr<Channel> InProcessChannelWithInterceptors(
116 std::unique_ptr<experimental::ClientInterceptorFactoryInterface>>
117 interceptor_creators);
175 std::shared_ptr<std::vector<std::unique_ptr<ServerCompletionQueue>>>
177 int min_pollers,
int max_pollers,
int sync_cq_timeout_msec,
180 std::unique_ptr<experimental::ServerInterceptorFactoryInterface>>
181 interceptor_creators = std::vector<std::unique_ptr<
195 std::vector<std::unique_ptr<experimental::ServerInterceptorFactoryInterface>>*
196 interceptor_creators()
override {
197 return &interceptor_creators_;
205 class CallbackRequest;
206 class UnimplementedAsyncRequest;
207 class UnimplementedAsyncResponse;
213 class SyncRequestThreadManager;
224 int max_receive_message_size()
const override {
225 return max_receive_message_size_;
237 std::vector<std::unique_ptr<experimental::ServerInterceptorFactoryInterface>>
238 interceptor_creators_;
240 const int max_receive_message_size_;
245 std::shared_ptr<std::vector<std::unique_ptr<ServerCompletionQueue>>>
250 std::vector<std::unique_ptr<SyncRequestThreadManager>> sync_req_mgrs_;
257 std::vector<gpr_atm> callback_unmatched_reqs_count_;
260 std::list<CallbackRequest*> callback_reqs_to_start_;
266 bool shutdown_notified_;
268 std::condition_variable shutdown_cv_;
277 std::mutex callback_reqs_mu_;
278 std::condition_variable callback_reqs_done_cv_;
279 std::atomic_int callback_reqs_outstanding_{0};
281 std::shared_ptr<GlobalCallbacks> global_callbacks_;
283 std::vector<grpc::string> services_;
284 bool has_generic_service_;
289 std::unique_ptr<ServerInitializer> server_initializer_;
291 std::unique_ptr<HealthCheckServiceInterface> health_check_service_;
292 bool health_check_service_disabled_;
295 std::unique_ptr<internal::MethodHandler> resource_exhausted_handler_;
307 #endif // GRPCPP_SERVER_H
bool RegisterService(const grpc::string *host, Service *service) override
Register a service.
std::string string
Definition: config.h:35
void Start(ServerCompletionQueue **cqs, size_t num_cqs) override
Start the server.
void Wait() override
Block until the server shuts down.
virtual void AddPort(Server *server, const grpc::string &addr, ServerCredentials *creds, int port)
Called after a server port is added.
Definition: server.h:82
Options for channel creation.
Definition: channel_arguments.h:39
Desriptor of an RPC service and its various RPC methods.
Definition: service_type.h:58
Definition: server_initializer.h:32
struct grpc_server grpc_server
A server listens to some port and responds to request calls.
Definition: grpc_types.h:65
virtual ~GlobalCallbacks()
Definition: server.h:72
Definition: async_generic_service.h:65
static void SetGlobalCallbacks(GlobalCallbacks *callbacks)
Set the global callback object.
Classes that require gRPC to be initialized should inherit from this class.
Definition: grpc_library.h:38
Definition: server_interceptor.h:45
grpc_server * server() override
Definition: server.h:192
The gRPC server uses this interface to expose the health checking service without depending on protob...
Definition: health_check_service_interface.h:31
virtual void PreSynchronousRequest(ServerContext *context)=0
Called before application callback for each synchronous server request.
virtual void PreServerStart(Server *server)
Called before server is started.
Definition: server.h:80
int AddListeningPort(const grpc::string &addr, ServerCredentials *creds) override
Try binding the server to the given addr endpoint (port, and optionally including IP address to bind ...
Wrapper around grpc_server_credentials, a way to authenticate a server.
Definition: server_credentials.h:35
Represents a gRPC server.
Definition: server.h:54
This header provides an object that reads bytes directly from a grpc::ByteBuffer, via the ZeroCopyInp...
Definition: alarm.h:24
NOTE: class experimental_type is not part of the public API of this class.
Definition: server.h:107
A ServerContext allows the person implementing a service handler to:
Definition: server_context.h:109
Definition: server_interface.h:50
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue.h).
Definition: completion_queue.h:97
experimental_type(Server *server)
Definition: server.h:109
An abstract collection of call ops, used to generate the grpc_call_op structure to pass down to the l...
Definition: call_op_set_interface.h:34
experimental_type experimental()
NOTE: The function experimental() is not stable public API.
Definition: server.h:126
Global callbacks are a set of hooks that are called when server events occur.
Definition: server.h:70
struct grpc_resource_quota grpc_resource_quota
Definition: grpc_types.h:645
Analogous to struct timespec.
Definition: gpr_types.h:47
grpc_server * c_server()
Returns a raw pointer to the underlying grpc_server instance.
virtual void UpdateArguments(ChannelArguments *args)
Called before server is created.
Definition: server.h:74
A specific type of completion queue used by the processing of notifications by servers.
Definition: completion_queue.h:384
virtual void PostSynchronousRequest(ServerContext *context)=0
Called after application callback for each synchronous server request.
A builder class for the creation and startup of grpc::Server instances.
Definition: server_builder.h:53
std::shared_ptr< Channel > InProcessChannel(const ChannelArguments &args)
Establish a channel for in-process communication.
Server(int max_message_size, 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, grpc_resource_quota *server_rq=nullptr, std::vector< std::unique_ptr< experimental::ServerInterceptorFactoryInterface >> interceptor_creators=std::vector< std::unique_ptr< experimental::ServerInterceptorFactoryInterface >>())
NOTE: This is NOT a public API.
Straightforward wrapping of the C call object.
Definition: call.h:36
HealthCheckServiceInterface * GetHealthCheckService() const
Returns the health check service.
Definition: server.h:97