From aadb00755f5c4372174c94b010c0e7c29c301178 Mon Sep 17 00:00:00 2001 From: fengweihao Date: Mon, 8 Jun 2020 17:17:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=99=90=E6=B5=81Handle?= =?UTF-8?q?=E6=9C=AA=E5=88=9D=E5=A7=8B=E5=8C=96db=5Findex=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/pangu/pangu_pxy.conf | 1 + plugin/business/pangu-http/src/pangu_http.cpp | 3 +++ 2 files changed, 4 insertions(+) diff --git a/conf/pangu/pangu_pxy.conf b/conf/pangu/pangu_pxy.conf index 49f2c50..088b1fe 100644 --- a/conf/pangu/pangu_pxy.conf +++ b/conf/pangu/pangu_pxy.conf @@ -55,6 +55,7 @@ enable=0 token_name=ratelimit redis_server=192.168.40.137 redis_port=6379 +redis_db_index=5 [maat] # 0:json 1: redis 2: iris diff --git a/plugin/business/pangu-http/src/pangu_http.cpp b/plugin/business/pangu-http/src/pangu_http.cpp index b7053a4..b88b1d0 100644 --- a/plugin/business/pangu-http/src/pangu_http.cpp +++ b/plugin/business/pangu-http/src/pangu_http.cpp @@ -988,6 +988,7 @@ error_out: Ratelimiter_handle_t ratelimit_handle_create(const char* profile_path, const char* static_section) { int ret=0, field_stat=0; + int redis_db_idx = 0; int redis_port = 0, interval_sec = 0; char redis_server[TFE_STRING_MAX] = {0}; char token_name[TFE_STRING_MAX] = {0}; @@ -998,6 +999,7 @@ Ratelimiter_handle_t ratelimit_handle_create(const char* profile_path, const cha MESA_load_profile_int_def(profile_path, static_section, "redis_port", &(redis_port), 6379); MESA_load_profile_string_def(profile_path, static_section, "redis_server", redis_server, sizeof(redis_server), ""); MESA_load_profile_string_def(profile_path, static_section, "token_name", token_name, sizeof(token_name), ""); + MESA_load_profile_int_def(profile_path, static_section, "redis_db_index", &(redis_db_idx), 0); MESA_load_profile_int_def(profile_path, static_section, "interval_sec", &(interval_sec), 1); if (g_pangu_rt->enable_rate != 1) @@ -1008,6 +1010,7 @@ Ratelimiter_handle_t ratelimit_handle_create(const char* profile_path, const cha Ratelimiter_set_opt(ratelimit, RATELIMITER_OPT_INTERVAL_SEC, &interval_sec, sizeof(interval_sec)); Ratelimiter_set_opt(ratelimit, RATELIMITER_OPT_REDIS_IP, redis_server, strlen(redis_server) + 1); Ratelimiter_set_opt(ratelimit, RATELIMITER_OPT_REDIS_PORT, &redis_port, sizeof(redis_port)); + Ratelimiter_set_opt(ratelimit, RATELIMITER_OPT_REDIS_INDEX, &redis_db_idx, sizeof(redis_db_idx)); /*field stata for debug test**/ MESA_load_profile_int_def(profile_path, static_section, "field_stat", &(field_stat), 0);