Git Product home page Git Product logo

srv-request's Introduction

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.

If the SRV lookup fails, then it will attempt to make the request anyway (so it will just do a standard DNS lookup)

srv-request's People

Contributors

jongretar avatar markgandy avatar terencehuynh avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.