lua-resty-core
lua-resty-core copied to clipboard
ngx.balancer 如何设置重试状态码
想要使用 ngx.balancer 设置在 404 的时候进行重试,ngx.balancer 支持吗
I think you can learn form: https://github.com/openresty/lua-resty-core/blob/99603e5a743b4fb0f6491a10f90c6f1b1ab4d7d9/t/balancer.t#L179-L230
- use the get_last_failure to get 404
- use set_more_tries to set more retry
just an idea.
ngx.balancer的重试机制好像只有在机器故障,或者是超时的时候才进行重试
如果机器是正常的,只是返回的状态码异常,是不会触发重试机制的,这个时候 local state, status = b.get_last_failure() 返回的结果是nil,nil
最关键的是如何触发这个重试机制