Skip to content

Commit 3fa8e15

Browse files
committed
Create get_endpoint_string and refactor
1 parent 22f2305 commit 3fa8e15

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

rootfs/etc/nginx/lua/test/balancer/sticky_test.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ describe("Sticky", function()
7373
end)
7474

7575
local test_backend = get_test_backend()
76-
local test_backend_endpoint= test_backend.endpoints[1].address .. ":" .. test_backend.endpoints[1].port
76+
local test_backend_endpoint= util.get_endpoint_string(test_backend.endpoints[1])
7777

7878
local legacy_cookie_value = test_backend_endpoint
7979
local function create_current_cookie_value(backend_key)

rootfs/etc/nginx/lua/util.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@ local re_gmatch = ngx.re.gmatch
1313

1414
local _M = {}
1515

16+
function _M.get_endpoint_string(endpoint)
17+
return endpoint.address .. ":" .. endpoint.port
18+
end
19+
1620
function _M.get_nodes(endpoints)
1721
local nodes = {}
1822
local weight = 1
1923

2024
for _, endpoint in pairs(endpoints) do
21-
local endpoint_string = endpoint.address .. ":" .. endpoint.port
25+
local endpoint_string = _M.get_endpoint_string(endpoint)
2226
nodes[endpoint_string] = weight
2327
end
2428

0 commit comments

Comments
 (0)