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/04/22 08:36:35 UTC
[GitHub] [apisix] Firstsawyou opened a new pull request #4109: feat: support to fetch balancer ip/port from ctx.var
Firstsawyou opened a new pull request #4109:
URL: https://github.com/apache/apisix/pull/4109
### 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. -->
Signed-off-by: Firstsawyou yuelinz99@gmail.com
close #4091
### Pre-submission checklist:
* [x] Did you explain what problem does this PR solve? Or what new features have been added?
* [x] 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] Firstsawyou commented on a change in pull request #4109: feat: support to fetch balancer ip/port from ctx.var
Posted by GitBox <gi...@apache.org>.
Firstsawyou commented on a change in pull request #4109:
URL: https://github.com/apache/apisix/pull/4109#discussion_r618245171
##########
File path: t/core/ctx2.t
##########
@@ -87,3 +87,58 @@ GET /xxx
--- error_log
pre uri: /hello
post uri: /server_port
+
+
+
+=== TEST 3: get balancer_ip and balancer_port through ctx.var
+--- 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": {
+ "serverless-post-function": {
+ "phase": "log",
+ "functions" : ["return function(conf, ctx)
+ ngx.log(ngx.WARN, 'balancer_ip: ', ctx.var.balancer_ip);
+ ngx.log(ngx.WARN, 'balancer_port: ', ctx.var.balancer_port);
+ end"]
+ }
+ },
+ "upstream": {
+ "nodes": {
+ "127.0.0.1:1980": 1
+ },
+ "type": "roundrobin"
+ }
+ }]]
+ )
+
+ if code >= 300 then
+ ngx.status = code
+ end
+ ngx.say(body)
+ }
+ }
+--- request
Review comment:
Got it, updated.
--
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 #4109: feat: support to fetch balancer ip/port from ctx.var
Posted by GitBox <gi...@apache.org>.
spacewander commented on a change in pull request #4109:
URL: https://github.com/apache/apisix/pull/4109#discussion_r618229768
##########
File path: t/core/ctx2.t
##########
@@ -87,3 +87,58 @@ GET /xxx
--- error_log
pre uri: /hello
post uri: /server_port
+
+
+
+=== TEST 3: get balancer_ip and balancer_port through ctx.var
+--- 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": {
+ "serverless-post-function": {
+ "phase": "log",
+ "functions" : ["return function(conf, ctx)
+ ngx.log(ngx.WARN, 'balancer_ip: ', ctx.var.balancer_ip);
+ ngx.log(ngx.WARN, 'balancer_port: ', ctx.var.balancer_port);
+ end"]
+ }
+ },
+ "upstream": {
+ "nodes": {
+ "127.0.0.1:1980": 1
+ },
+ "type": "roundrobin"
+ }
+ }]]
+ )
+
+ if code >= 300 then
+ ngx.status = code
+ end
+ ngx.say(body)
+ }
+ }
+--- request
Review comment:
We don't need that stuff. They are already set in https://github.com/Firstsawyou/apisix/blob/a78bd10f4f1efb3547cae880d7cdea7d7ffb08e1/t/core/ctx2.t#L23
--
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 #4109: feat: support to fetch balancer ip/port from ctx.var
Posted by GitBox <gi...@apache.org>.
tokers commented on a change in pull request #4109:
URL: https://github.com/apache/apisix/pull/4109#discussion_r618297188
##########
File path: t/core/ctx2.t
##########
@@ -87,3 +87,52 @@ GET /xxx
--- error_log
pre uri: /hello
post uri: /server_port
+
+
+
+=== TEST 3: get balancer_ip and balancer_port through ctx.var
+--- 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": {
+ "serverless-post-function": {
+ "phase": "log",
+ "functions" : ["return function(conf, ctx)
+ ngx.log(ngx.WARN, 'balancer_ip: ', ctx.var.balancer_ip);
Review comment:
Redundant semicolons.
--
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] Firstsawyou commented on a change in pull request #4109: feat: support to fetch balancer ip/port from ctx.var
Posted by GitBox <gi...@apache.org>.
Firstsawyou commented on a change in pull request #4109:
URL: https://github.com/apache/apisix/pull/4109#discussion_r618310129
##########
File path: t/core/ctx2.t
##########
@@ -87,3 +87,52 @@ GET /xxx
--- error_log
pre uri: /hello
post uri: /server_port
+
+
+
+=== TEST 3: get balancer_ip and balancer_port through ctx.var
+--- 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": {
+ "serverless-post-function": {
+ "phase": "log",
+ "functions" : ["return function(conf, ctx)
+ ngx.log(ngx.WARN, 'balancer_ip: ', ctx.var.balancer_ip);
Review comment:
Got it, updated.
--
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 #4109: feat: support to fetch balancer ip/port from ctx.var
Posted by GitBox <gi...@apache.org>.
spacewander merged pull request #4109:
URL: https://github.com/apache/apisix/pull/4109
--
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