Go to the documentation of this file.
19 #ifndef GRPCPP_SERVER_BUILDER_H
20 #define GRPCPP_SERVER_BUILDER_H
43 class CompletionQueue;
45 class ServerCompletionQueue;
46 class AsyncGenericService;
48 class ServerCredentials;
51 class ServerBuilderPluginTest;
55 class ExternalConnectionAcceptorImpl;
58 #ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL
59 namespace experimental {
61 class CallbackGenericService;
62 #ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL
66 namespace experimental {
132 const std::string& addr_uri,
133 std::shared_ptr<grpc::ServerCredentials> creds,
134 int* selected_port =
nullptr);
167 bool is_frequently_polled =
true);
192 max_receive_message_size_ = max_receive_message_size;
199 max_send_message_size_ = max_send_message_size;
251 std::unique_ptr<grpc::ServerBuilderPlugin> (*CreatePlugin)());
266 std::vector<std::unique_ptr<
268 interceptor_creators) {
269 builder_->interceptor_creators_ = std::move(interceptor_creators);
275 std::unique_ptr<grpc::ContextAllocator> context_allocator);
277 #ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL
294 std::unique_ptr<grpc::experimental::ExternalConnectionAcceptor>
296 std::shared_ptr<ServerCredentials> creds);
302 #ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
308 grpc::CallbackGenericService* service);
320 std::shared_ptr<ServerCredentials>
creds;
335 std::vector<Port>
ports() {
return ports_; }
339 std::vector<NamedService*> service_refs;
340 for (
auto& ptr : services_) {
341 service_refs.push_back(ptr.get());
347 std::vector<grpc::ServerBuilderOption*>
options() {
348 std::vector<grpc::ServerBuilderOption*> option_refs;
349 for (
auto& ptr : options_) {
350 option_refs.push_back(ptr.get());
357 server_config_fetcher_ = server_config_fetcher;
361 friend class ::grpc::testing::ServerBuilderPluginTest;
363 struct SyncServerSettings {
365 : num_cqs(1), min_pollers(1), max_pollers(2), cq_timeout_msec(10000) {}
382 int max_receive_message_size_;
383 int max_send_message_size_;
384 std::vector<std::unique_ptr<grpc::ServerBuilderOption>> options_;
385 std::vector<std::unique_ptr<NamedService>> services_;
386 std::vector<Port> ports_;
388 SyncServerSettings sync_server_settings_;
391 std::vector<grpc::ServerCompletionQueue*> cqs_;
393 std::shared_ptr<grpc::ServerCredentials> creds_;
394 std::vector<std::unique_ptr<grpc::ServerBuilderPlugin>> plugins_;
397 std::unique_ptr<ContextAllocator> context_allocator_;
398 #ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
399 grpc::CallbackGenericService* callback_generic_service_{
nullptr};
408 } maybe_default_compression_level_;
412 } maybe_default_compression_algorithm_;
413 uint32_t enabled_compression_algorithms_bitset_;
415 std::unique_ptr<grpc::experimental::ServerInterceptorFactoryInterface>>
416 interceptor_creators_;
417 std::vector<std::shared_ptr<grpc::internal::ExternalConnectionAcceptorImpl>>
424 #endif // GRPCPP_SERVER_BUILDER_H
grpc_compression_level level
Definition: server_builder.h:407
Definition: server_builder.h:326
virtual std::unique_ptr< grpc::Server > BuildAndStart()
Return a running server which is ready for processing calls.
grpc_compression_algorithm algorithm
Definition: server_builder.h:411
std::unique_ptr< ServerBuilderOption > MakeChannelArgumentOption(const std::string &name, const std::string &value)
ServerBuilder & SetDefaultCompressionAlgorithm(grpc_compression_algorithm algorithm)
The default compression algorithm to use for all channel calls in the absence of a call-specific leve...
ServerBuilder & EnableWorkaround(grpc_workaround_list id)
Enable a server workaround.
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm.h:33
struct grpc_resource_quota grpc_resource_quota
Definition: grpc_types.h:698
std::vector< Port > ports()
Experimental, to be deprecated.
Definition: server_builder.h:335
NamedService(const std::string &h, grpc::Service *s)
Definition: server_builder.h:328
grpc_compression_algorithm
The various compression algorithms supported by gRPC (not sorted by compression level)
Definition: compression_types.h:57
std::unique_ptr< grpc::experimental::ExternalConnectionAcceptor > AddExternalConnectionAcceptor(ExternalConnectionType type, std::shared_ptr< ServerCredentials > creds)
Register an acceptor to handle the externally accepted connection in grpc server.
std::string addr
Definition: server_builder.h:319
void set_fetcher(grpc_server_config_fetcher *server_config_fetcher)
Experimental API, subject to change.
Definition: server_builder.h:356
Desriptor of an RPC service and its various RPC methods.
Definition: service_type.h:56
static void InternalAddPluginFactory(std::unique_ptr< grpc::ServerBuilderPlugin >(*CreatePlugin)())
For internal use only: Register a ServerBuilderPlugin factory function.
Experimental, to be deprecated.
Definition: server_builder.h:318
struct grpc_server_config_fetcher grpc_server_config_fetcher
Definition: grpc.h:414
int * selected_port
Definition: server_builder.h:321
@ NUM_CQS
Number of completion queues.
Definition: server_builder.h:233
ExternalConnectionType
Definition: server_builder.h:286
ByteBuffer read_buffer
Definition: server_builder.h:76
Definition: server_builder.h:73
int fd
Definition: server_builder.h:75
@ MAX_POLLERS
Maximum number of polling threads.
Definition: server_builder.h:235
ServerBuilder & SetDefaultCompressionLevel(grpc_compression_level level)
The default compression level to use for all channel calls in the absence of a call-specific level.
A sequence of bytes.
Definition: byte_buffer.h:61
experimental_type(ServerBuilder *builder)
Definition: server_builder.h:263
ResourceQuota represents a bound on memory and thread usage by the gRPC library.
Definition: resource_quota.h:34
std::unique_ptr< std::string > HostString
Experimental, to be deprecated.
Definition: server_builder.h:325
ServerBuilder & RegisterAsyncGenericService(grpc::AsyncGenericService *service)
Register a generic service.
CallbackGenericService is the base class for generic services implemented using the callback API and ...
Definition: async_generic_service.h:106
ServerBuilder & SetContextAllocator(std::unique_ptr< grpc::ContextAllocator > context_allocator)
Set the allocator for creating and releasing callback server context.
NOTE: class experimental_type is not part of the public API of this class.
Definition: server_builder.h:261
Definition: async_generic_service.h:68
Definition: server_builder.h:71
@ CQ_TIMEOUT_MSEC
Completion queue timeout in milliseconds.
Definition: server_builder.h:236
ServerBuilder & SetMaxMessageSize(int max_message_size)
Definition: server_builder.h:204
ServerBuilder & SetSyncServerOption(SyncServerOption option, int value)
Only useful if this is a Synchronous server.
ServerBuilder & SetCompressionAlgorithmSupportStatus(grpc_compression_algorithm algorithm, bool enabled)
Set the support status for compression algorithms.
SyncServerOption
Options for synchronous servers.
Definition: server_builder.h:232
std::vector< NamedService * > services()
Experimental, to be deprecated.
Definition: server_builder.h:338
Definition: server_interceptor.h:43
grpc::Service * service
Definition: server_builder.h:331
ServerBuilder & RegisterCallbackGenericService(grpc::experimental::CallbackGenericService *service)
Register a generic service that uses the callback API.
bool is_set
Definition: server_builder.h:406
std::unique_ptr< grpc::ServerCompletionQueue > AddCompletionQueue(bool is_frequently_polled=true)
Add a completion queue for handling asynchronous services.
std::shared_ptr< ServerCredentials > creds
Definition: server_builder.h:320
HostString host
Definition: server_builder.h:330
grpc_workaround_list
Definition: workaround_list.h:26
grpc_compression_level
Compression levels allow a party with knowledge of its peer's accepted encodings to request compressi...
Definition: compression_types.h:71
Definition: async_unary_call.h:398
virtual ~ExternalConnectionAcceptor()
Definition: server_builder.h:78
ServerBuilder & SetResourceQuota(const grpc::ResourceQuota &resource_quota)
Set the attached buffer pool for this server.
void SetInterceptorCreators(std::vector< std::unique_ptr< grpc::experimental::ServerInterceptorFactoryInterface >> interceptor_creators)
Definition: server_builder.h:265
NamedService(grpc::Service *s)
Definition: server_builder.h:327
ServerBuilder & AddListeningPort(const std::string &addr_uri, std::shared_ptr< grpc::ServerCredentials > creds, int *selected_port=nullptr)
Enlists an endpoint addr (port with an optional IP address) to bind the grpc::Server object to be cre...
virtual void HandleNewConnection(NewConnectionParameters *p)=0
int listener_fd
Definition: server_builder.h:74
experimental_type experimental()
NOTE: The function experimental() is not stable public API.
Definition: server_builder.h:314
A builder class for the creation and startup of grpc::Server instances.
Definition: server_builder.h:90
ServerBuilder & SetOption(std::unique_ptr< grpc::ServerBuilderOption > option)
ServerBuilder & SetMaxReceiveMessageSize(int max_receive_message_size)
Set max receive message size in bytes.
Definition: server_builder.h:191
std::vector< grpc::ServerBuilderOption * > options()
Experimental, to be deprecated.
Definition: server_builder.h:347
ServerBuilder & AddChannelArgument(const std::string &arg, const T &value)
Add a channel argument (an escape hatch to tuning core library parameters directly)
Definition: server_builder.h:245
@ MIN_POLLERS
Minimum number of polling threads.
Definition: server_builder.h:234
ServerBuilder & SetMaxSendMessageSize(int max_send_message_size)
Set max send message size in bytes.
Definition: server_builder.h:198
ServerBuilder & RegisterService(grpc::Service *service)
Register a service.