19 #ifndef GRPCPP_SERVER_BUILDER_IMPL_H 20 #define GRPCPP_SERVER_BUILDER_IMPL_H 50 class AsyncGenericService;
53 class ServerBuilderPluginTest;
57 class ExternalConnectionAcceptorImpl;
60 namespace experimental {
61 class CallbackGenericService;
127 std::shared_ptr<grpc_impl::ServerCredentials> creds,
128 int* selected_port =
nullptr);
161 bool is_frequently_polled =
true);
186 max_receive_message_size_ = max_receive_message_size;
193 max_send_message_size_ = max_send_message_size;
246 std::unique_ptr<grpc::ServerBuilderPlugin> (*CreatePlugin)());
259 : builder_(builder) {}
262 std::vector<std::unique_ptr<
264 interceptor_creators) {
265 builder_->interceptor_creators_ = std::move(interceptor_creators);
283 std::unique_ptr<grpc::experimental::ExternalConnectionAcceptor>
285 std::shared_ptr<ServerCredentials> creds);
300 std::shared_ptr<grpc_impl::ServerCredentials>
creds;
315 std::vector<Port>
ports() {
return ports_; }
319 std::vector<NamedService*> service_refs;
320 for (
auto& ptr : services_) {
321 service_refs.push_back(ptr.get());
327 std::vector<grpc::ServerBuilderOption*>
options() {
328 std::vector<grpc::ServerBuilderOption*> option_refs;
329 for (
auto& ptr : options_) {
330 option_refs.push_back(ptr.get());
336 friend class ::grpc::testing::ServerBuilderPluginTest;
338 struct SyncServerSettings {
340 : num_cqs(1), min_pollers(1), max_pollers(2), cq_timeout_msec(10000) {}
357 int max_receive_message_size_;
358 int max_send_message_size_;
359 std::vector<std::unique_ptr<grpc::ServerBuilderOption>> options_;
360 std::vector<std::unique_ptr<NamedService>> services_;
361 std::vector<Port> ports_;
363 SyncServerSettings sync_server_settings_;
366 std::vector<grpc_impl::ServerCompletionQueue*> cqs_;
368 std::shared_ptr<grpc_impl::ServerCredentials> creds_;
369 std::vector<std::unique_ptr<grpc::ServerBuilderPlugin>> plugins_;
377 } maybe_default_compression_level_;
381 } maybe_default_compression_algorithm_;
382 uint32_t enabled_compression_algorithms_bitset_;
384 std::unique_ptr<grpc::experimental::ServerInterceptorFactoryInterface>>
385 interceptor_creators_;
386 std::vector<std::shared_ptr<grpc::internal::ExternalConnectionAcceptorImpl>>
392 #endif // GRPCPP_SERVER_BUILDER_IMPL_H std::unique_ptr< ServerBuilderOption > MakeChannelArgumentOption(const grpc::string &name, const grpc::string &value)
Definition: channel_argument_option.cc:23
ExternalConnectionType
Definition: server_builder_impl.h:275
ServerBuilder & EnableWorkaround(grpc_workaround_list id)
Enable a server workaround.
Definition: server_builder.cc:413
ServerBuilder & RegisterCallbackGenericService(grpc::experimental::CallbackGenericService *service)
Register a generic service that uses the callback API.
Definition: server_builder.cc:104
grpc_compression_algorithm algorithm
Definition: server_builder_impl.h:380
int * selected_port
Definition: server_builder_impl.h:301
std::string string
Definition: config.h:35
Maximum number of polling threads.
Definition: server_builder_impl.h:230
::grpc_impl::ServerCredentials ServerCredentials
Definition: server_credentials.h:30
virtual ~ServerBuilder()
Definition: server_builder.cc:64
int listener_fd
Definition: server_builder_impl.h:70
ServerBuilder & SetDefaultCompressionAlgorithm(grpc_compression_algorithm algorithm)
The default compression algorithm to use for all channel calls in the absence of a call-specific leve...
Definition: server_builder.cc:172
::grpc_impl::Server Server
Definition: server.h:26
Desriptor of an RPC service and its various RPC methods.
Definition: service_type.h:60
std::unique_ptr< grpc_impl::ServerCompletionQueue > AddCompletionQueue(bool is_frequently_polled=true)
Add a completion queue for handling asynchronous services.
Definition: server_builder.cc:70
int fd
Definition: server_builder_impl.h:71
::grpc_impl::ResourceQuota ResourceQuota
Definition: resource_quota.h:26
Experimental, to be deprecated.
Definition: server_builder_impl.h:298
Definition: server_builder_impl.h:67
ServerBuilder()
Definition: server_builder.cc:45
grpc_compression_level
Compression levels allow a party with knowledge of its peer's accepted encodings to request compressi...
Definition: compression_types.h:71
std::vector< grpc::ServerBuilderOption * > options()
Experimental, to be deprecated.
Definition: server_builder_impl.h:327
Definition: async_generic_service.h:75
Definition: server_interceptor.h:47
::grpc_impl::ServerCompletionQueue ServerCompletionQueue
Definition: completion_queue.h:27
ServerBuilder & SetDefaultCompressionLevel(grpc_compression_level level)
The default compression level to use for all channel calls in the absence of a call-specific level...
Definition: server_builder.cc:165
SyncServerOption
Options for synchronous servers.
Definition: server_builder_impl.h:227
::grpc_impl::CompletionQueue CompletionQueue
Definition: completion_queue.h:26
Number of completion queues.
Definition: server_builder_impl.h:228
static void InternalAddPluginFactory(std::unique_ptr< grpc::ServerBuilderPlugin >(*CreatePlugin)())
For internal use only: Register a ServerBuilderPlugin factory function.
Definition: server_builder.cc:407
NOTE: class experimental_type is not part of the public API of this class.
Definition: server_builder_impl.h:256
grpc_compression_algorithm
The various compression algorithms supported by gRPC (not sorted by compression level) ...
Definition: compression_types.h:57
ServerBuilder & SetCompressionAlgorithmSupportStatus(grpc_compression_algorithm algorithm, bool enabled)
Set the support status for compression algorithms.
Definition: server_builder.cc:155
NamedService(grpc::Service *s)
Definition: server_builder_impl.h:307
ServerBuilder & RegisterService(grpc::Service *service)
Register a service.
Definition: server_builder.cc:80
ServerBuilder & SetMaxReceiveMessageSize(int max_receive_message_size)
Set max receive message size in bytes.
Definition: server_builder_impl.h:185
This header provides an object that reads bytes directly from a grpc::ByteBuffer, via the ZeroCopyInp...
Definition: alarm.h:24
virtual std::unique_ptr< grpc::Server > BuildAndStart()
Return a running server which is ready for processing calls.
Definition: server_builder.cc:204
grpc_workaround_list
Definition: workaround_list.h:26
ServerBuilder & SetResourceQuota(const grpc_impl::ResourceQuota &resource_quota)
Set the attached buffer pool for this server.
Definition: server_builder.cc:179
virtual ~ExternalConnectionAcceptor()
Definition: server_builder_impl.h:74
std::vector< Port > ports()
Experimental, to be deprecated.
Definition: server_builder_impl.h:315
ByteBuffer read_buffer
Definition: server_builder_impl.h:72
HostString host
Definition: server_builder_impl.h:310
grpc_compression_level level
Definition: server_builder_impl.h:376
ServerBuilder & SetMaxMessageSize(int max_message_size)
Definition: server_builder_impl.h:198
bool is_set
Definition: server_builder_impl.h:375
ServerBuilder & SetSyncServerOption(SyncServerOption option, int value)
Only useful if this is a Synchronous server.
Definition: server_builder.cc:136
grpc::string addr
Definition: server_builder_impl.h:299
ServerBuilder & AddListeningPort(const grpc::string &addr_uri, std::shared_ptr< grpc_impl::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...
Definition: server_builder.cc:189
grpc::Service * service
Definition: server_builder_impl.h:311
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm_impl.h:33
CallbackGenericService is the base class for generic services implemented using the callback API and ...
Definition: async_generic_service.h:121
Minimum number of polling threads.
Definition: server_builder_impl.h:229
experimental_type experimental()
NOTE: The function experimental() is not stable public API.
Definition: server_builder_impl.h:294
std::unique_ptr< grpc::string > HostString
Experimental, to be deprecated.
Definition: server_builder_impl.h:305
struct grpc_resource_quota grpc_resource_quota
Definition: grpc_types.h:677
Definition: server_builder_impl.h:306
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. ...
Definition: server_builder.cc:118
std::shared_ptr< grpc_impl::ServerCredentials > creds
Definition: server_builder_impl.h:300
ServerBuilder & SetMaxSendMessageSize(int max_send_message_size)
Set max send message size in bytes.
Definition: server_builder_impl.h:192
Definition: server_builder_impl.h:69
ServerBuilder & RegisterAsyncGenericService(grpc::AsyncGenericService *service)
Register a generic service.
Definition: server_builder.cc:91
NamedService(const grpc::string &h, grpc::Service *s)
Definition: server_builder_impl.h:308
A sequence of bytes.
Definition: byte_buffer.h:67
ServerBuilder & SetOption(std::unique_ptr< grpc::ServerBuilderOption > option)
Definition: server_builder.cc:130
A builder class for the creation and startup of grpc::Server instances.
Definition: server_builder_impl.h:86
std::vector< NamedService * > services()
Experimental, to be deprecated.
Definition: server_builder_impl.h:318
experimental_type(grpc_impl::ServerBuilder *builder)
Definition: server_builder_impl.h:258
ResourceQuota represents a bound on memory and thread usage by the gRPC library.
Definition: resource_quota_impl.h:34
virtual void HandleNewConnection(NewConnectionParameters *p)=0
void SetInterceptorCreators(std::vector< std::unique_ptr< grpc::experimental::ServerInterceptorFactoryInterface >> interceptor_creators)
Definition: server_builder_impl.h:261
ServerBuilder & AddChannelArgument(const grpc::string &arg, const T &value)
Add a channel argument (an escape hatch to tuning core library parameters directly) ...
Definition: server_builder_impl.h:240
Completion queue timeout in milliseconds.
Definition: server_builder_impl.h:231