Skip to content

Commit 8f6cdae

Browse files
authored
feat:调整构建脚本,删除nginx代码 (#13)
* feat:调整构建脚本,删除nginx代码 * 使用rm -f防止删除失败 * feat; 无需执行清理逻辑 * feat: 修改nginx限流的问题
1 parent 7d4907a commit 8f6cdae

File tree

407 files changed

+22
-222469
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

407 files changed

+22
-222469
lines changed

.github/workflows/testing.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,8 @@ jobs:
1313

1414
steps:
1515
- uses: actions/checkout@v2
16-
- name: clean
17-
run: |
18-
pushd build
19-
./clean.sh
20-
popd
2116
- name: make
2217
run: |
2318
pushd build
24-
./make.sh
19+
bash make.sh
2520
popd

build/build.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ echo "build nginx-gateway for version ${version}"
1010
pushd ../third_party
1111
rm -rf polaris-cpp
1212
git clone -b release_v1.1.0 https://github.com/polarismesh/polaris-cpp polaris-cpp
13+
rm -rf nginx-1.18.0
14+
curl http://nginx.org/download/nginx-1.18.0.tar.gz -o nginx-1.18.0.tar.gz
15+
tar xf nginx-1.18.0.tar.gz
16+
cp nginx/make nginx-1.18.0/auto/
17+
1318

1419
pushd polaris-cpp
1520
make

build/clean.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

build/make.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ set -e
55
pushd ../third_party
66
rm -rf polaris-cpp
77
git clone -b release_v1.1.0 https://github.com/polarismesh/polaris-cpp polaris-cpp
8+
rm -rf nginx-1.18.0
9+
curl http://nginx.org/download/nginx-1.18.0.tar.gz -o nginx-1.18.0.tar.gz
10+
tar xf nginx-1.18.0.tar.gz
811

912
pushd polaris-cpp
1013
make

polaris.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,11 @@ global:
88
#类型:list
99
addresses:
1010
- ${polaris_address} # 埋点地址
11+
# 描述:限流相关配置
12+
rateLimiter:
13+
# 分布式限流时用于发现限流服务器
14+
rateLimitCluster:
15+
# 限流服务器集群所在命名空间
16+
namespace: Polaris
17+
# 限流服务器集群名字
18+
service: polaris.limiter

source/nginx_polaris_limit_module/ngx_http_polaris_limit_module.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,16 @@ static ngx_int_t ngx_http_polaris_limit_handler(ngx_http_request_t *r) {
107107
}
108108

109109
get_labels_from_request(r, label_keys, labels); // 从http 请求中获取labels
110-
110+
std::string uri(reinterpret_cast<char *>(r->uri.data), r->uri.len);
111111
quota_request.SetServiceNamespace(service_namespace); // 设置限流规则对应服务的命名空间
112112
quota_request.SetServiceName(service_name); // 设置限流规则对应的服务名
113+
quota_request.SetMethod(uri);
113114
quota_request.SetLabels(labels); // 设置label用于匹配限流规则
114115

115116
std::string labels_values_str;
116117
join_map_str(r->connection->log, labels, labels_values_str);
117118
ngx_log_debug(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
118-
"[PolarisRateLimiting] quota_request namespace %s, service %s, labels %s", service_namespace.c_str(), service_name.c_str(), labels_values_str.c_str());
119+
"[PolarisRateLimiting] quota_request namespace %s, service %s, method %s, labels %s", service_namespace.c_str(), service_name.c_str(), uri.c_str(), labels_values_str.c_str());
119120

120121
ret = Limit_API_SINGLETON.GetLimitApi()->GetQuota(quota_request, result);
121122

@@ -173,7 +174,7 @@ static char *ngx_http_polaris_limit_conf_set(ngx_conf_t *cf, ngx_command_t *cmd,
173174
} else {
174175
ngx_str_t namespace_str = {value[i].len - KEY_NAMESPACE_SIZE, &value[i].data[KEY_NAMESPACE_SIZE]};
175176
plcf->service_namespace = namespace_str;
176-
ngx_conf_log_error(NGX_LOG_NOTICE, cf, 0, "[PolarisRateLimiting] use %v as nginx namespace", namespace_str);
177+
ngx_conf_log_error(NGX_LOG_NOTICE, cf, 0, "[PolarisRateLimiting] use %V as nginx namespace", &namespace_str);
177178
}
178179
continue;
179180
}
@@ -187,7 +188,7 @@ static char *ngx_http_polaris_limit_conf_set(ngx_conf_t *cf, ngx_command_t *cmd,
187188
ngx_conf_log_error(NGX_LOG_ERR, cf, 0, "[PolarisRateLimiting] service name not set");
188189
return static_cast<char *>(NGX_CONF_ERROR);
189190
} else {
190-
ngx_conf_log_error(NGX_LOG_NOTICE, cf, 0, "[PolarisRateLimiting] use %v as service", svc_name_str);
191+
ngx_conf_log_error(NGX_LOG_NOTICE, cf, 0, "[PolarisRateLimiting] use %V as service", &svc_name_str);
191192
}
192193
continue;
193194
}

0 commit comments

Comments
 (0)