nodejs / undici

An HTTP/1.1 client, written from scratch for Node.js
https://nodejs.github.io/undici
MIT License
5.92k stars 511 forks source link

dns round-robin interceptor + cache #3350

Open ronag opened 1 week ago

ronag commented 1 week ago
class Handler {
  // 1. resolve dns entries
  // 2. pick an ip for entry list
  // 3. const origin = new URL(opts.origin)
  // 4. origin.hostname = ip
  // 3. call dispatch({ ...opts, origin }, handler)
}

export const dnsInterceptor = dispatch => (opts, handler) => isDNSName(opts.origin.hostname)
  ? dispatch(opts, new Handler(opts, { dispatch, handler }))
  : dispatch(opts, handler)
ronag commented 1 week ago

@metcoder95

mcollina commented 1 week ago

this would need to implement Happy Eyeballs.

metcoder95 commented 1 week ago

This could be interesting, I was thinking about the same with the other closed issue but was unsure; if we are able to implement it with Happy Eyeballs will be really beneficial.

It could be good to also pick-up different strategies for distributing the load, possibly weighted or based on response.