From ad8cccf2547e20f531019f0f83c6e11b3dd6de2b Mon Sep 17 00:00:00 2001 From: Qian Sun Date: Thu, 16 Feb 2017 14:18:24 -0800 Subject: [PATCH] Remove group rules. --- contrib/endpoints/src/api_manager/config.cc | 17 +---------------- contrib/endpoints/src/api_manager/method_impl.h | 15 ++++++++------- 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/contrib/endpoints/src/api_manager/config.cc b/contrib/endpoints/src/api_manager/config.cc index dda4feb8be2..50504083100 100644 --- a/contrib/endpoints/src/api_manager/config.cc +++ b/contrib/endpoints/src/api_manager/config.cc @@ -121,22 +121,7 @@ bool Config::LoadQuotaRule(ApiManagerEnvInterface *env) { (*method)->add_metric_cost(metric_cost.first, metric_cost.second); } } else { - env->LogDebug("Method not Found."); - } - } - - for (const auto &rule : service_.quota().rules()) { - auto method = utils::FindOrNull(method_map_, rule.selector()); - if (method) { - for (const auto &group_name : rule.groups()) { - for (const auto &group : service_.quota().groups()) { - if (group.name() == group_name.group()) { - for (const auto &limit : group.limits()) { - (*method)->add_metric_cost(limit.metric(), group_name.cost()); - } - } - } - } + env->LogError("Metric rule with selector is mismatched."); } } diff --git a/contrib/endpoints/src/api_manager/method_impl.h b/contrib/endpoints/src/api_manager/method_impl.h index f05e7806c80..d6eaba33724 100644 --- a/contrib/endpoints/src/api_manager/method_impl.h +++ b/contrib/endpoints/src/api_manager/method_impl.h @@ -18,6 +18,7 @@ #include #include #include +#include #include "contrib/endpoints/include/api_manager/method.h" #include "contrib/endpoints/src/api_manager/utils/stl_util.h" @@ -62,8 +63,8 @@ class MethodInfoImpl : public MethodInfo { const std::string &backend_address() const { return backend_address_; } - const std::map &metric_cost_map() const { - return metric_cost_map_; + const std::vector> &metric_cost_vector() const { + return metric_cost_vector_; } const std::string &rpc_method_full_name() const { @@ -95,7 +96,7 @@ class MethodInfoImpl : public MethodInfo { } void add_metric_cost(const std::string &metric, int64_t cost) { - metric_cost_map_[metric] = cost; + metric_cost_vector_.push_back(std::make_pair(metric, cost)); } // After add all system parameters, lookup some of them to cache @@ -147,13 +148,13 @@ class MethodInfoImpl : public MethodInfo { // such as API Key)? bool allow_unregistered_calls_; // Issuers to allowed audiences map. - std::map > issuer_audiences_map_; + std::map> issuer_audiences_map_; // system parameter map of parameter name to http_header name. - std::map > http_header_parameters_; + std::map> http_header_parameters_; // system parameter map of parameter name to url query parameter name. - std::map > url_query_parameters_; + std::map> url_query_parameters_; // all the names of system query parameters std::set system_query_parameter_names_; @@ -185,7 +186,7 @@ class MethodInfoImpl : public MethodInfo { bool response_streaming_; // map of metric and its cost - std::map metric_cost_map_; + std::vector> metric_cost_vector_; }; typedef std::unique_ptr MethodInfoImplPtr;