lua-resty-core icon indicating copy to clipboard operation
lua-resty-core copied to clipboard

feature: added new Lua API for Nginx core's dynamic resolver (FFI).

Open slimboyfat opened this issue 5 years ago • 2 comments

I hereby granted the copyright of the changes in this pull request to the authors of this lua-resty-core project.

slimboyfat avatar Mar 06 '19 21:03 slimboyfat

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.

mikz avatar Apr 17 '19 11:04 mikz

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?

slimboyfat avatar Apr 18 '19 19:04 slimboyfat