Skip to content
Snippets Groups Projects
Commit cdc0d03b authored by Muxi Yan's avatar Muxi Yan
Browse files

Add EnableWorkaround API to enable server workarounds

parent e74b9aea
No related branches found
No related tags found
No related merge requests found
......@@ -184,6 +184,11 @@ class ServerBuilder {
static void InternalAddPluginFactory(
std::unique_ptr<ServerBuilderPlugin> (*CreatePlugin)());
/// Enable a server workaround. Do not use unless you know what the workaround
/// does. For explanation and detailed descriptions of workarounds, see
/// docs/workarounds.md.
ServerBuilder& EnableWorkaround(uint32_t id);
private:
friend class ::grpc::testing::ServerBuilderPluginTest;
......@@ -226,6 +231,7 @@ class ServerBuilder {
std::vector<std::unique_ptr<ServerBuilderOption>> options_;
std::vector<std::unique_ptr<NamedService>> services_;
std::vector<Port> ports_;
std::vector<const char *> enabled_workarounds_;
SyncServerSettings sync_server_settings_;
......
......@@ -39,6 +39,7 @@
#include <grpc/support/cpu.h>
#include <grpc/support/log.h>
#include <grpc/support/useful.h>
#include <grpc/support/workaround_list.h>
#include "src/cpp/server/thread_pool_interface.h"
......@@ -198,6 +199,10 @@ std::unique_ptr<Server> ServerBuilder::BuildAndStart() {
args.SetInt(GRPC_ARG_MAX_SEND_MESSAGE_LENGTH, max_send_message_size_);
}
for (auto workaround : enabled_workarounds_) {
args.SetInt(workaround, 1);
}
args.SetInt(GRPC_COMPRESSION_CHANNEL_ENABLED_ALGORITHMS_BITSET,
enabled_compression_algorithms_bitset_);
if (maybe_default_compression_level_.is_set) {
......@@ -358,4 +363,14 @@ void ServerBuilder::InternalAddPluginFactory(
(*g_plugin_factory_list).push_back(CreatePlugin);
}
void ServerBuilder::EnableWorkaround(uint32_t id) {
switch (id) {
case GRPC_WORKAROUND_ID_CRONET_COMPRESSION:
enabled_workarounds_.push_back(GRPC_ARG_WORKAROUND_CRONET_COMPRESSION);
break;
default:
gpr_log(GPR_ERROR, "Workaround %u is not exist or obsolete.", id);
}
}
} // namespace grpc
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment