Revert changes to optional

reviewable/pr18746/r8
Yash Tibrewal 6 years ago
parent b476a30e69
commit d3035a3d5f
  1. 16
      src/core/ext/filters/client_channel/resolver_result_parsing.cc
  2. 4
      src/core/ext/filters/client_channel/resolver_result_parsing.h
  3. 1
      src/core/lib/gprpp/optional.h

@ -416,8 +416,8 @@ ClientChannelServiceConfigParser::ParseGlobalParams(const grpc_json* json,
"field:retryThrottling error:Type should be object"));
continue;
}
Optional<int> max_milli_tokens;
Optional<int> milli_token_ratio;
Optional<int> max_milli_tokens = Optional<int>();
Optional<int> milli_token_ratio = Optional<int>();
for (grpc_json* sub_field = field->child; sub_field != nullptr;
sub_field = sub_field->next) {
if (sub_field->key == nullptr) continue;
@ -492,20 +492,20 @@ ClientChannelServiceConfigParser::ParseGlobalParams(const grpc_json* json,
}
}
}
ClientChannelGlobalParsedObject::RetryThrottling data;
if (!max_milli_tokens.has_value()) {
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"field:retryThrottling field:maxTokens error:Not found"));
} else {
data.max_milli_tokens = max_milli_tokens.value();
}
if (!milli_token_ratio.has_value()) {
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"field:retryThrottling field:tokenRatio error:Not found"));
}
if (error_list.size() == 0) {
ClientChannelGlobalParsedObject::RetryThrottling data;
data.max_milli_tokens = max_milli_tokens.value();
} else {
data.milli_token_ratio = milli_token_ratio.value();
retry_throttling.set(data);
}
retry_throttling.set(data);
}
if (strcmp(field->key, "healthCheckConfig") == 0) {
if (health_check_service_name != nullptr) {
@ -535,7 +535,7 @@ ClientChannelServiceConfigParser::ParsePerMethodParams(const grpc_json* json,
grpc_error** error) {
GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE);
InlinedVector<grpc_error*, 4> error_list;
Optional<bool> wait_for_ready;
Optional<bool> wait_for_ready = Optional<bool>();
grpc_millis timeout = 0;
UniquePtr<ClientChannelMethodParsedObject::RetryPolicy> retry_policy;
for (grpc_json* field = json->child; field != nullptr; field = field->next) {

@ -74,7 +74,7 @@ class ClientChannelGlobalParsedObject : public ServiceConfig::ParsedConfig {
RefCountedPtr<ParsedLoadBalancingConfig> parsed_lb_config_;
UniquePtr<char> parsed_deprecated_lb_policy_;
Optional<RetryThrottling> retry_throttling_;
const char* health_check_service_name_ = nullptr;
const char* health_check_service_name_;
};
class ClientChannelMethodParsedObject : public ServiceConfig::ParsedConfig {
@ -173,7 +173,7 @@ class ProcessedResolverResult {
// Retry throttle data.
Optional<ClientChannelGlobalParsedObject::RetryThrottling>
retry_throttle_data_;
const char* health_check_service_name_;
const char* health_check_service_name_ = nullptr;
};
} // namespace internal

@ -26,7 +26,6 @@ namespace grpc_core {
template <typename T>
class Optional {
public:
Optional() { value_ = T(); }
void set(const T& val) {
value_ = val;
set_ = true;

Loading…
Cancel
Save