@localz/srv-request
Extends Request with DNS SRV record lookup
Last updated 3 years ago by localzadmin .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @localz/srv-request 
SYNC missed versions from official npm registry.

SRV Request

Extends Request with lookup of DNS SRV records.

Use just as you would Request except that instead of the hostname in the URI you use the SRV record host. A random host will be chosen from the SRV results.

Given the following example setup created using SkyDNS and Registrator:

root@server1:~# dig SRV myservice.skydns.local
...
;; QUESTION SECTION:
;myservice.skydns.local.	IN	SRV
;; ANSWER SECTION:
myservice.skydns.local. 33 IN	SRV	10 100 8110 server1-myservice-8000.myservice.skydns.local.
myservice.skydns.local. 33 IN	SRV	10 100 8110 server2-myservice-8000.myservice.skydns.local.
;; ADDITIONAL SECTION:
server1-myservice-8000.myservice.skydns.local. 33 IN A 10.10.10.30
server2-myservice-8000.myservice.skydns.local. 33 IN A 10.10.10.40
...

You will make your request as such:

var request = require('srv-request');
request('http://myservice.skydns.local/v1/ping', function (error, response, body) {
	console.log(error, body)
});

The HTTP requests will then be made to the URI: http://server1-myservice-8000.myservice.skydns.local:8110/v1/ping.

Current Tags

  • 1.0.0                                ...           latest (3 years ago)

1 Versions

  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 2
Last Month 2
Dependencies (1)
Dev Dependencies (1)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |