lua-resty-core
lua-resty-core copied to clipboard
feature: added new Lua API for Nginx core's dynamic resolver (FFI).
I hereby granted the copyright of the changes in this pull request to the authors of this lua-resty-core project.
This looks useful, but maybe it would be better to design it more future-proof? What about using this for custom load balancing in balancer_by_lua? This would need to return all the resolved addresses, so the balancer code can do the decision. What about other classes than A records? SRV for example?
If this API exists, I think it should aim to replace the need for https://github.com/openresty/lua-resty-dns.
Yes, it can be extended to retrieve all entries from DNS response and return Lua table. At the moment, only A and AAAA records are supported, but add support for SRV-records is not a big deal (as Nginx internal resolver supports SRV queries).
Benefits of proposed ngx.resolve() API are
- configurable caching policy;
- ability to efficiently handle sequential queries for a same host;
@agentzh had several remarks on correctness of proposed implementation, but he possible is busy and can not help me.
@agentzh, @thibaultcha, can you help me?