node-statsd icon indicating copy to clipboard operation
node-statsd copied to clipboard

Client: Constructor supports createSocket option

Open dm03514 opened this issue 6 years ago • 0 comments

Refs #77

This change allows clients to configure a custom createSocket method to use for socket construction. The example below shows how clients on newer versions of node, with statsd daemons running locally, could provide a socket constructor to bypass DNS lookups:

var statsd = new StatsD({
        createSocket: function() {
          return dgram.createSocket({
              type: 'udp4',
              lookup: function() { 
                const cb = arguments[arguments.length -1];
                cb(null, '127.0.0.1', 4);
              }
          });
        }
      });

This is useful to allow

dm03514 avatar Oct 11 '19 16:10 dm03514