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/09/03 02:53:46 UTC
[GitHub] [apisix] tzssangglass commented on a change in pull request #4965: feat(proxy-mirror): support mirror requests percentage
tzssangglass commented on a change in pull request #4965:
URL: https://github.com/apache/apisix/pull/4965#discussion_r701547185
##########
File path: apisix/plugins/proxy-mirror.lua
##########
@@ -15,7 +15,7 @@
-- limitations under the License.
--
local core = require("apisix.core")
-
+local math = math
Review comment:
```suggestion
local math_random = math.random
```
##########
File path: apisix/plugins/proxy-mirror.lua
##########
@@ -53,7 +59,17 @@ function _M.rewrite(conf, ctx)
core.log.info("proxy mirror plugin rewrite phase, conf: ", core.json.delay_encode(conf))
ctx.var.upstream_host = ctx.var.host
- ctx.var.upstream_mirror_host = conf.host
+
+ if not conf.percentage or conf.percentage == 1 then
+ ctx.var.upstream_mirror_host = conf.host
+ else
+ local val = math.random()
Review comment:
```suggestion
local val = math_random()
```
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org