3 * Copyright 2018 gRPC authors.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 #ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_RESULT_PARSING_H
20 #define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_RESULT_PARSING_H
22 #include <grpc/support/port_platform.h>
24 #include "src/core/ext/filters/client_channel/lb_policy.h"
25 #include "src/core/ext/filters/client_channel/lb_policy_factory.h"
26 #include "src/core/ext/filters/client_channel/resolver.h"
27 #include "src/core/ext/filters/client_channel/retry_throttle.h"
28 #include "src/core/ext/filters/client_channel/service_config.h"
29 #include "src/core/lib/channel/status_util.h"
30 #include "src/core/lib/gprpp/optional.h"
31 #include "src/core/lib/gprpp/ref_counted.h"
32 #include "src/core/lib/gprpp/ref_counted_ptr.h"
33 #include "src/core/lib/iomgr/exec_ctx.h" // for grpc_millis
34 #include "src/core/lib/json/json.h"
35 #include "src/core/lib/slice/slice_hash_table.h"
40 class ClientChannelGlobalParsedConfig : public ServiceConfig::ParsedConfig {
42 struct RetryThrottling {
43 intptr_t max_milli_tokens = 0;
44 intptr_t milli_token_ratio = 0;
47 ClientChannelGlobalParsedConfig(
48 RefCountedPtr<LoadBalancingPolicy::Config> parsed_lb_config,
49 UniquePtr<char> parsed_deprecated_lb_policy,
50 const Optional<RetryThrottling>& retry_throttling,
51 const char* health_check_service_name)
52 : parsed_lb_config_(std::move(parsed_lb_config)),
53 parsed_deprecated_lb_policy_(std::move(parsed_deprecated_lb_policy)),
54 retry_throttling_(retry_throttling),
55 health_check_service_name_(health_check_service_name) {}
57 Optional<RetryThrottling> retry_throttling() const {
58 return retry_throttling_;
61 RefCountedPtr<LoadBalancingPolicy::Config> parsed_lb_config() const {
62 return parsed_lb_config_;
65 const char* parsed_deprecated_lb_policy() const {
66 return parsed_deprecated_lb_policy_.get();
69 const char* health_check_service_name() const {
70 return health_check_service_name_;
74 RefCountedPtr<LoadBalancingPolicy::Config> parsed_lb_config_;
75 UniquePtr<char> parsed_deprecated_lb_policy_;
76 Optional<RetryThrottling> retry_throttling_;
77 const char* health_check_service_name_;
80 class ClientChannelMethodParsedConfig : public ServiceConfig::ParsedConfig {
84 grpc_millis initial_backoff = 0;
85 grpc_millis max_backoff = 0;
86 float backoff_multiplier = 0;
87 StatusCodeSet retryable_status_codes;
90 ClientChannelMethodParsedConfig(grpc_millis timeout,
91 const Optional<bool>& wait_for_ready,
92 UniquePtr<RetryPolicy> retry_policy)
94 wait_for_ready_(wait_for_ready),
95 retry_policy_(std::move(retry_policy)) {}
97 grpc_millis timeout() const { return timeout_; }
99 Optional<bool> wait_for_ready() const { return wait_for_ready_; }
101 const RetryPolicy* retry_policy() const { return retry_policy_.get(); }
104 grpc_millis timeout_ = 0;
105 Optional<bool> wait_for_ready_;
106 UniquePtr<RetryPolicy> retry_policy_;
109 class ClientChannelServiceConfigParser : public ServiceConfig::Parser {
111 UniquePtr<ServiceConfig::ParsedConfig> ParseGlobalParams(
112 const grpc_json* json, grpc_error** error) override;
114 UniquePtr<ServiceConfig::ParsedConfig> ParsePerMethodParams(
115 const grpc_json* json, grpc_error** error) override;
117 static size_t ParserIndex();
118 static void Register();
121 } // namespace internal
122 } // namespace grpc_core
124 #endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_RESOLVER_RESULT_PARSING_H */