Skip to content

Commit

Permalink
Remove group rules.
Browse files Browse the repository at this point in the history
  • Loading branch information
chowchow316 committed Feb 16, 2017
1 parent 497a261 commit 0df1229
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
17 changes: 1 addition & 16 deletions contrib/endpoints/src/api_manager/config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
}

Expand Down
9 changes: 5 additions & 4 deletions contrib/endpoints/src/api_manager/method_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <map>
#include <memory>
#include <set>
#include <vector>

#include "contrib/endpoints/include/api_manager/method.h"
#include "contrib/endpoints/src/api_manager/utils/stl_util.h"
Expand Down Expand Up @@ -62,8 +63,8 @@ class MethodInfoImpl : public MethodInfo {

const std::string &backend_address() const { return backend_address_; }

const std::map<std::string, int64_t> &metric_cost_map() const {
return metric_cost_map_;
const std::vector<std::pair<std::string, int>> &metric_cost_vector() const {
return metric_cost_vector_;
}

const std::string &rpc_method_full_name() const {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -185,7 +186,7 @@ class MethodInfoImpl : public MethodInfo {
bool response_streaming_;

// map of metric and its cost
std::map<std::string, int64_t> metric_cost_map_;
std::vector<std::pair<std::string, int>> metric_cost_vector_;
};

typedef std::unique_ptr<MethodInfoImpl> MethodInfoImplPtr;
Expand Down

0 comments on commit 0df1229

Please sign in to comment.