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/07 10:22:40 UTC

[GitHub] [apisix] membphis commented on a change in pull request #4965: feat(proxy-mirror): support mirror requests sample_ratio

membphis commented on a change in pull request #4965:
URL: https://github.com/apache/apisix/pull/4965#discussion_r703381800



##########
File path: apisix/plugins/proxy-mirror.lua
##########
@@ -53,7 +59,18 @@ 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.sample_ratio or conf.sample_ratio == 1 then
+        ctx.var.upstream_mirror_host = conf.host
+    else
+        local val = math_random()
+        core.log.info("mirror request sample_ratio conf: ", conf.sample_ratio,
+            ", random value: ", val)

Review comment:
       bad indentation




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