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);