nginx-nacos-upstream icon indicating copy to clipboard operation
nginx-nacos-upstream copied to clipboard

讨论贴:现在已经支持 nginx 了,但是用起来有点不灵活。计划做一次大重构,全面支持 openresty,计划如下

Open zhwaaaaaa opened this issue 9 months ago • 5 comments

支持 配置 订阅 支持 lua 回调

新增 如下命令,用于支持 配置的 lua 回调

subscribe_config_by_lua_block data_id=xxxx group=xxx {
    local config_data = nacos.get_current_config_data()
    local config_md5 = nacos.get_current_config_md5()
    --- 通过 lua 自行处理 nacos 推送的配置
    ngx.log(ngx.ERR, "config_data="..config_data.."   config_md5="..config_md5)
}

lua 中支持 动态订阅 配置

-- 支持 lua 动态订阅配置
nacos.subscribe_config(data_id=xxxx, group=xxx, function(config_data, config_md5)
    --- 通过 lua 自行处理 nacos 推送的配置
    ngx.log(ngx.ERR, "config_data="..config_data.."   config_md5="..config_md5)
end)

lua 中支持 直接查询配置,非订阅

-- 支持 lua 动态订阅配置
local config_data, config_md5 = nacos.query_config(data_id=xxxx, group=xxx)
--- 通过 lua 自行处理 nacos 推送的配置
ngx.log(ngx.ERR, "config_data="..config_data.."   config_md5="..config_md5)

lua 中支持动态订阅服务

-- 支持 lua 动态订阅配置
nacos.subscribe_service(service_name=xxxx, group=xxx)

lua 中获取 服务的 地址列表

-- 支持 lua 动态订阅配置
nacos.get_service_result(service_name=xxxx, group=xxx)

zhwaaaaaa avatar May 21 '24 14:05 zhwaaaaaa