diff options
Diffstat (limited to 'include/grpc++/server_builder.h')
-rw-r--r-- | include/grpc++/server_builder.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/include/grpc++/server_builder.h b/include/grpc++/server_builder.h index 37f1f8cb80..9252c6a63a 100644 --- a/include/grpc++/server_builder.h +++ b/include/grpc++/server_builder.h @@ -34,6 +34,7 @@ #ifndef GRPCXX_SERVER_BUILDER_H #define GRPCXX_SERVER_BUILDER_H +#include <climits> #include <map> #include <memory> #include <vector> @@ -42,10 +43,15 @@ #include <grpc++/impl/server_builder_plugin.h> #include <grpc++/support/config.h> #include <grpc/compression.h> +#include <grpc/support/cpu.h> +#include <grpc/support/useful.h> + +struct grpc_resource_quota; namespace grpc { class AsyncGenericService; +class ResourceQuota; class CompletionQueue; class RpcService; class Server; @@ -61,6 +67,9 @@ class ServerBuilderPluginTest; class ServerBuilder { public: ServerBuilder(); + ~ServerBuilder(); + + enum SyncServerOption { NUM_CQS, MIN_POLLERS, MAX_POLLERS, CQ_TIMEOUT_MSEC }; /// Register a service. This call does not take ownership of the service. /// The service must exist for the lifetime of the \a Server instance returned @@ -113,8 +122,14 @@ class ServerBuilder { ServerBuilder& SetDefaultCompressionAlgorithm( grpc_compression_algorithm algorithm); + /// Set the attached buffer pool for this server + ServerBuilder& SetResourceQuota(const ResourceQuota& resource_quota); + ServerBuilder& SetOption(std::unique_ptr<ServerBuilderOption> option); + /// Only useful if this is a Synchronous server. + ServerBuilder& SetSyncServerOption(SyncServerOption option, int value); + /// Tries to bind \a server to the given \a addr. /// /// It can be invoked multiple times. @@ -170,6 +185,28 @@ class ServerBuilder { int* selected_port; }; + struct SyncServerSettings { + SyncServerSettings() + : num_cqs(GPR_MAX(gpr_cpu_num_cores(), 4)), + min_pollers(1), + max_pollers(INT_MAX), + cq_timeout_msec(1000) {} + + // Number of server completion queues to create to listen to incoming RPCs. + int num_cqs; + + // Minimum number of threads per completion queue that should be listening + // to incoming RPCs. + int min_pollers; + + // Maximum number of threads per completion queue that can be listening to + // incoming RPCs. + int max_pollers; + + // The timeout for server completion queue's AsyncNext call. + int cq_timeout_msec; + }; + typedef std::unique_ptr<grpc::string> HostString; struct NamedService { explicit NamedService(Service* s) : service(s) {} @@ -184,9 +221,15 @@ class ServerBuilder { std::vector<std::unique_ptr<ServerBuilderOption>> options_; std::vector<std::unique_ptr<NamedService>> services_; std::vector<Port> ports_; + + SyncServerSettings sync_server_settings_; + + // List of completion queues added via AddCompletionQueue() method std::vector<ServerCompletionQueue*> cqs_; + std::shared_ptr<ServerCredentials> creds_; std::vector<std::unique_ptr<ServerBuilderPlugin>> plugins_; + grpc_resource_quota* resource_quota_; AsyncGenericService* generic_service_; struct { bool is_set; |