@@ -66,29 +66,43 @@ class ServerBuilder {
6666 // / The service must exist for the lifetime of the \a Server instance returned
6767 // / by \a BuildAndStart().
6868 // / Matches requests with any :authority
69- void RegisterService (Service* service);
69+ ServerBuilder& RegisterService (Service* service);
7070
7171 // / Register a generic service.
7272 // / Matches requests with any :authority
73- void RegisterAsyncGenericService (AsyncGenericService* service);
73+ ServerBuilder& RegisterAsyncGenericService (AsyncGenericService* service);
7474
7575 // / Register a service. This call does not take ownership of the service.
7676 // / The service must exist for the lifetime of the \a Server instance returned
7777 // / by BuildAndStart().
7878 // / Only matches requests with :authority \a host
79- void RegisterService (const grpc::string& host, Service* service);
79+ ServerBuilder& RegisterService (const grpc::string& host, Service* service);
8080
8181 // / Set max message size in bytes.
82- void SetMaxMessageSize (int max_message_size) {
82+ ServerBuilder& SetMaxMessageSize (int max_message_size) {
8383 max_message_size_ = max_message_size;
84+ return *this ;
8485 }
8586
86- // / Set the compression options to be used by the server.
87- void SetCompressionOptions (const grpc_compression_options& options) {
88- compression_options_ = options;
89- }
87+ // / Set the support status for compression algorithms. All algorithms are
88+ // / enabled by default.
89+ // /
90+ // / Incoming calls compressed with an unsupported algorithm will fail with
91+ // / GRPC_STATUS_UNIMPLEMENTED.
92+ ServerBuilder& SetCompressionAlgorithmSupportStatus (
93+ grpc_compression_algorithm algorithm, bool enabled);
94+
95+ // / The default compression level to use for all channel calls in the
96+ // / absence of a call-specific level.
97+ ServerBuilder& SetDefaultCompressionLevel (grpc_compression_level level);
98+
99+ // / The default compression algorithm to use for all channel calls in the
100+ // / absence of a call-specific level. Note that it overrides any compression
101+ // / level set by \a SetDefaultCompressionLevel.
102+ ServerBuilder& SetDefaultCompressionAlgorithm (
103+ grpc_compression_algorithm algorithm);
90104
91- void SetOption (std::unique_ptr<ServerBuilderOption> option);
105+ ServerBuilder& SetOption (std::unique_ptr<ServerBuilderOption> option);
92106
93107 // / Tries to bind \a server to the given \a addr.
94108 // /
@@ -101,9 +115,9 @@ class ServerBuilder {
101115 // / number. \a nullptr otherwise.
102116 // /
103117 // TODO(dgq): the "port" part seems to be a misnomer.
104- void AddListeningPort (const grpc::string& addr,
105- std::shared_ptr<ServerCredentials> creds,
106- int * selected_port = nullptr );
118+ ServerBuilder& AddListeningPort (const grpc::string& addr,
119+ std::shared_ptr<ServerCredentials> creds,
120+ int * selected_port = nullptr );
107121
108122 // / Add a completion queue for handling asynchronous services
109123 // / Caller is required to keep this completion queue live until
@@ -144,14 +158,22 @@ class ServerBuilder {
144158 };
145159
146160 int max_message_size_;
147- grpc_compression_options compression_options_;
148161 std::vector<std::unique_ptr<ServerBuilderOption>> options_;
149162 std::vector<std::unique_ptr<NamedService>> services_;
150163 std::vector<Port> ports_;
151164 std::vector<ServerCompletionQueue*> cqs_;
152165 std::shared_ptr<ServerCredentials> creds_;
153166 std::map<grpc::string, std::unique_ptr<ServerBuilderPlugin>> plugins_;
154167 AsyncGenericService* generic_service_;
168+ struct {
169+ bool is_set;
170+ grpc_compression_level level;
171+ } maybe_default_compression_level_;
172+ struct {
173+ bool is_set;
174+ grpc_compression_algorithm algorithm;
175+ } maybe_default_compression_algorithm_;
176+ uint32_t enabled_compression_algorithms_bitset_;
155177};
156178
157179} // namespace grpc
0 commit comments