mirror of
https://gitee.com/iresty/apisix.git
synced 2024-12-16 01:41:17 +08:00
7ee7029720
* benchmark: added benchmark scripts. * feature: added fake apisix, compare the result with this fake apisix server.
53 lines
984 B
Lua
53 lines
984 B
Lua
local balancer = require "ngx.balancer"
|
|
local _M = {version = 0.1}
|
|
|
|
function _M.http_init()
|
|
end
|
|
|
|
function _M.http_init_worker()
|
|
end
|
|
|
|
local function fake_fetch()
|
|
ngx.ctx.ip = "127.0.0.1"
|
|
ngx.ctx.port = 80
|
|
end
|
|
|
|
function _M.http_access_phase()
|
|
local uri = ngx.var.uri
|
|
local host = ngx.var.host
|
|
local method = ngx.req.get_method()
|
|
local remote_addr = ngx.var.remote_addr
|
|
fake_fetch(uri, host, method, remote_addr)
|
|
end
|
|
|
|
function _M.http_header_filter_phase()
|
|
if ngx.ctx then
|
|
-- do something
|
|
end
|
|
end
|
|
|
|
function _M.http_log_phase()
|
|
if ngx.ctx then
|
|
-- do something
|
|
end
|
|
end
|
|
|
|
function _M.http_admin()
|
|
end
|
|
|
|
function _M.http_ssl_phase()
|
|
if ngx.ctx then
|
|
-- do something
|
|
end
|
|
end
|
|
|
|
function _M.http_balancer_phase()
|
|
local ok, err = balancer.set_current_peer(ngx.ctx.ip, ngx.ctx.port)
|
|
if not ok then
|
|
ngx.log(ngx.ERR, "failed to set the current peer: ", err)
|
|
return ngx.exit(500)
|
|
end
|
|
end
|
|
|
|
return _M
|