Skip to content
Snippets Groups Projects
Commit d3035a3d authored by Yash Tibrewal's avatar Yash Tibrewal
Browse files

Revert changes to optional

parent b476a30e
No related branches found
No related tags found
No related merge requests found
...@@ -416,8 +416,8 @@ ClientChannelServiceConfigParser::ParseGlobalParams(const grpc_json* json, ...@@ -416,8 +416,8 @@ ClientChannelServiceConfigParser::ParseGlobalParams(const grpc_json* json,
"field:retryThrottling error:Type should be object")); "field:retryThrottling error:Type should be object"));
continue; continue;
} }
Optional<int> max_milli_tokens; Optional<int> max_milli_tokens = Optional<int>();
Optional<int> milli_token_ratio; Optional<int> milli_token_ratio = Optional<int>();
for (grpc_json* sub_field = field->child; sub_field != nullptr; for (grpc_json* sub_field = field->child; sub_field != nullptr;
sub_field = sub_field->next) { sub_field = sub_field->next) {
if (sub_field->key == nullptr) continue; if (sub_field->key == nullptr) continue;
...@@ -492,20 +492,20 @@ ClientChannelServiceConfigParser::ParseGlobalParams(const grpc_json* json, ...@@ -492,20 +492,20 @@ ClientChannelServiceConfigParser::ParseGlobalParams(const grpc_json* json,
} }
} }
} }
ClientChannelGlobalParsedObject::RetryThrottling data;
if (!max_milli_tokens.has_value()) { if (!max_milli_tokens.has_value()) {
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING( error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"field:retryThrottling field:maxTokens error:Not found")); "field:retryThrottling field:maxTokens error:Not found"));
} else {
data.max_milli_tokens = max_milli_tokens.value();
} }
if (!milli_token_ratio.has_value()) { if (!milli_token_ratio.has_value()) {
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING( error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"field:retryThrottling field:tokenRatio error:Not found")); "field:retryThrottling field:tokenRatio error:Not found"));
} } else {
if (error_list.size() == 0) {
ClientChannelGlobalParsedObject::RetryThrottling data;
data.max_milli_tokens = max_milli_tokens.value();
data.milli_token_ratio = milli_token_ratio.value(); data.milli_token_ratio = milli_token_ratio.value();
retry_throttling.set(data);
} }
retry_throttling.set(data);
} }
if (strcmp(field->key, "healthCheckConfig") == 0) { if (strcmp(field->key, "healthCheckConfig") == 0) {
if (health_check_service_name != nullptr) { if (health_check_service_name != nullptr) {
...@@ -535,7 +535,7 @@ ClientChannelServiceConfigParser::ParsePerMethodParams(const grpc_json* json, ...@@ -535,7 +535,7 @@ ClientChannelServiceConfigParser::ParsePerMethodParams(const grpc_json* json,
grpc_error** error) { grpc_error** error) {
GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE); GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE);
InlinedVector<grpc_error*, 4> error_list; InlinedVector<grpc_error*, 4> error_list;
Optional<bool> wait_for_ready; Optional<bool> wait_for_ready = Optional<bool>();
grpc_millis timeout = 0; grpc_millis timeout = 0;
UniquePtr<ClientChannelMethodParsedObject::RetryPolicy> retry_policy; UniquePtr<ClientChannelMethodParsedObject::RetryPolicy> retry_policy;
for (grpc_json* field = json->child; field != nullptr; field = field->next) { for (grpc_json* field = json->child; field != nullptr; field = field->next) {
......
...@@ -74,7 +74,7 @@ class ClientChannelGlobalParsedObject : public ServiceConfig::ParsedConfig { ...@@ -74,7 +74,7 @@ class ClientChannelGlobalParsedObject : public ServiceConfig::ParsedConfig {
RefCountedPtr<ParsedLoadBalancingConfig> parsed_lb_config_; RefCountedPtr<ParsedLoadBalancingConfig> parsed_lb_config_;
UniquePtr<char> parsed_deprecated_lb_policy_; UniquePtr<char> parsed_deprecated_lb_policy_;
Optional<RetryThrottling> retry_throttling_; Optional<RetryThrottling> retry_throttling_;
const char* health_check_service_name_ = nullptr; const char* health_check_service_name_;
}; };
class ClientChannelMethodParsedObject : public ServiceConfig::ParsedConfig { class ClientChannelMethodParsedObject : public ServiceConfig::ParsedConfig {
...@@ -173,7 +173,7 @@ class ProcessedResolverResult { ...@@ -173,7 +173,7 @@ class ProcessedResolverResult {
// Retry throttle data. // Retry throttle data.
Optional<ClientChannelGlobalParsedObject::RetryThrottling> Optional<ClientChannelGlobalParsedObject::RetryThrottling>
retry_throttle_data_; retry_throttle_data_;
const char* health_check_service_name_; const char* health_check_service_name_ = nullptr;
}; };
} // namespace internal } // namespace internal
......
...@@ -26,7 +26,6 @@ namespace grpc_core { ...@@ -26,7 +26,6 @@ namespace grpc_core {
template <typename T> template <typename T>
class Optional { class Optional {
public: public:
Optional() { value_ = T(); }
void set(const T& val) { void set(const T& val) {
value_ = val; value_ = val;
set_ = true; set_ = true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment