You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/02/08 10:02:21 UTC

[GitHub] [apisix] wettper opened a new pull request #3559: Feature/redis database

wettper opened a new pull request #3559:
URL: https://github.com/apache/apisix/pull/3559


   Under normal circumstances, Redis deploys and uses more than one database, so this time we added select database related functions, hoping to make some contributions to `apisix`
   
   
   ### What this PR does / why we need it:
   <!--- Why is this change required? What problem does it solve? -->
   <!--- If it fixes an open issue, please link to the issue here. -->
   
   ### Pre-submission checklist:
   
   * [ ] Did you explain what problem does this PR solve? Or what new features have been added?
   * [ ] Have you added corresponding test cases?
   * [ ] Have you modified the corresponding document?
   * [ ] Is this PR backward compatible? **If it is not backward compatible, please discuss on the [mailing list](https://github.com/apache/apisix/tree/master#community) first**
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] wettper commented on a change in pull request #3559: feat: add select database for Redis related functions

Posted by GitBox <gi...@apache.org>.
wettper commented on a change in pull request #3559:
URL: https://github.com/apache/apisix/pull/3559#discussion_r572645805



##########
File path: doc/zh-cn/plugins/limit-count.md
##########
@@ -44,6 +44,7 @@
 | redis_host      | string   | `redis` 必须 |         |                                                              | 当使用 `redis` 限速策略时,该属性是 Redis 服务节点的地址。   |
 | redis_port      | integer  | 可选         | 6379    | [1,...]                                                      | 当使用 `redis` 限速策略时,该属性是 Redis 服务节点的端口     |
 | redis_password  | string   | 可选         |         |                                                              | 当使用 `redis` 限速策略时,该属性是 Redis 服务节点的密码。   |
+| redis_database  | integer  | 可选         | 0       | redis_database >= 0                                          | 当使用 `redis` 限速策略时,该属性是 Redis 服务节点中使用的 database,并且只针对 非Redis集群模式(单实例模式 或者 提供单入口的Redis公有云服务)生效。   |

Review comment:
       Uh, yes, I modified the related grammar, thank you very much for reminding




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] spacewander commented on a change in pull request #3559: feat: add select database for Redis related functions

Posted by GitBox <gi...@apache.org>.
spacewander commented on a change in pull request #3559:
URL: https://github.com/apache/apisix/pull/3559#discussion_r572492776



##########
File path: t/plugin/limit-count-redis.t
##########
@@ -122,7 +122,146 @@ passed
 
 
 
-=== TEST 3: set route(default value: port and timeout)
+=== TEST 3: set route, with redis host and port and default database
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/routes/1',
+                ngx.HTTP_PUT,
+                [[{
+                    "uri": "/hello",
+                    "plugins": {
+                        "limit-count": {
+                            "count": 2,
+                            "time_window": 60,
+                            "rejected_code": 503,
+                            "key": "remote_addr",
+                            "policy": "redis",
+                            "redis_host": "127.0.0.1",
+                            "redis_port": 6379,
+                            "redis_timeout": 1001
+                        }
+                    },
+                    "upstream": {
+                        "nodes": {
+                            "127.0.0.1:1980": 1
+                        },
+                        "type": "roundrobin"
+                    }
+                }]]
+                )
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log
+[error]
+
+
+
+=== TEST 4: set route, with redis host and port but wrong database

Review comment:
       Better to add test case after the last one.
   And you need to use another test case to hit the route.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] wettper commented on a change in pull request #3559: feat: add select database for Redis related functions

Posted by GitBox <gi...@apache.org>.
wettper commented on a change in pull request #3559:
URL: https://github.com/apache/apisix/pull/3559#discussion_r572646433



##########
File path: t/plugin/limit-count-redis.t
##########
@@ -122,7 +122,146 @@ passed
 
 
 
-=== TEST 3: set route(default value: port and timeout)
+=== TEST 3: set route, with redis host and port and default database
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/routes/1',
+                ngx.HTTP_PUT,
+                [[{
+                    "uri": "/hello",
+                    "plugins": {
+                        "limit-count": {
+                            "count": 2,
+                            "time_window": 60,
+                            "rejected_code": 503,
+                            "key": "remote_addr",
+                            "policy": "redis",
+                            "redis_host": "127.0.0.1",
+                            "redis_port": 6379,
+                            "redis_timeout": 1001
+                        }
+                    },
+                    "upstream": {
+                        "nodes": {
+                            "127.0.0.1:1980": 1
+                        },
+                        "type": "roundrobin"
+                    }
+                }]]
+                )
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log
+[error]
+
+
+
+=== TEST 4: set route, with redis host and port but wrong database

Review comment:
       Uh, ok, I added a unit test file, and I am debugging related errors




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] wettper commented on pull request #3559: feat: add select database for Redis related functions

Posted by GitBox <gi...@apache.org>.
wettper commented on pull request #3559:
URL: https://github.com/apache/apisix/pull/3559#issuecomment-775874281


   @spacewander @tokers  Thank you both for your reminders, I have resubmitted...


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] tokers commented on a change in pull request #3559: feat: add select database for Redis related functions

Posted by GitBox <gi...@apache.org>.
tokers commented on a change in pull request #3559:
URL: https://github.com/apache/apisix/pull/3559#discussion_r572500125



##########
File path: doc/zh-cn/plugins/limit-count.md
##########
@@ -44,6 +44,7 @@
 | redis_host      | string   | `redis` 必须 |         |                                                              | 当使用 `redis` 限速策略时,该属性是 Redis 服务节点的地址。   |
 | redis_port      | integer  | 可选         | 6379    | [1,...]                                                      | 当使用 `redis` 限速策略时,该属性是 Redis 服务节点的端口     |
 | redis_password  | string   | 可选         |         |                                                              | 当使用 `redis` 限速策略时,该属性是 Redis 服务节点的密码。   |
+| redis_database  | integer  | 可选         | 0       | redis_database >= 0                                          | 当使用 `redis` 限速策略时,该属性是 Redis 服务节点中使用的 database,并且只针对 非Redis集群模式(单实例模式 或者 提供单入口的Redis公有云服务)生效。   |

Review comment:
       Some minor style problems: Keep empty space on both sides of English words. Remove redundant empty spaces between Chinese words.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] spacewander merged pull request #3559: feat: add select database for Redis related functions

Posted by GitBox <gi...@apache.org>.
spacewander merged pull request #3559:
URL: https://github.com/apache/apisix/pull/3559


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] wettper commented on pull request #3559: feat: add select database for Redis related functions

Posted by GitBox <gi...@apache.org>.
wettper commented on pull request #3559:
URL: https://github.com/apache/apisix/pull/3559#issuecomment-775893647


   @spacewander  Sorry, I accidentally clicked the "Re-request review" button ^*^
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org