npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mesosdns-client

v0.3.2

Published

A simple client for Mesos DNS which makes it possible to receive actual endpoints from Mesos service names

Downloads

19

Readme

mesosdns-client

A NPM package that resolves Mesos service URLs to actual host/port endpoints.

Installation

This package can be installed via running npm install mesosdns-client --save.

Options

The following options are available:

  • dnsServers: The array of available Mesos DNS servers (IP addresses)
  • mesosTLD: The TLD of Mesos, as defined in the Mesos DNS settings (default .mesos)
  • dnsTimeout: The timeout in milliseconds after which a DNS request is considered as timed out
  • defaultPortIndex: The global default "port index" which should be use (default is 0). Can be useful if querying services with multiple ports. To use the portIndex per call, see the get(serviceName, options, callback) function.
  • strategy: The strategy to choose an endpoint which should be used if there are more then one instances of the service/application. Default is weighted (by DNS prio/weight), or random.
  • healthCheckEnabled: If the health checks should be enabled (default is false). Should be set to true is mesosdns-client is used in a long-running application. This will then trigger recurrent health checks.
  • healthCheckInterval: The health check intervall in milliseconds (default is 10000). Should only be used if healthCheckEnabled is true
  • useEvents: Currently this just enables the displaying of debugging messages from the health checks if set to true (default is false)

Usage

To use the mesosdns-client, the Mesos DNS services have to be deployed (ideally) on each Mesos Slave. For example, if there's a web application deployed via Marathon (called web) on three instances, and Mesos DNS runs on the servers 192.168.0.100, 192.168.0.101 and 192.168.0.102, we can use it like this:

Basic usage

var MesosDNSClient = require("mesosdns-client");

var options = {
    dnsServers: ["192.168.0.100", "192.168.0.101", "192.168.0.102"],
    mesosTLD: ".mesos"
};

var client = new MesosDNSClient(options);

client.get("web.marathon.mesos", function(error, addressInfo) {
    if (error) console.log(JSON.stringify(error));
    
    console.log("The complete addressInfo is: " + JSON.stringify(addressInfo));
    console.log("The endpoint is: " + JSON.stringify(addressInfo.endpoint));
    
});

will print

The complete addressInfo is: {"hostname":"web.marathon.mesos","endpoint":"192.168.0.100:31302","host":"192.168.0.100","port":31302,"allEndpoints":[{"port":31302,"host":"192.168.0.100"},{"port":31205,"host":"192.168.0.101"},{"port":31695,"host":"192.168.0.102"}],"took":"18"}
The endpoint is: "192.168.200.168:31302"

If the requested hostname/service is a basic service, such as leader.mesos, the MesosDNSClient will resolve the A record instead of the SRV record. The output will then look like this:

{"serviceName": "master.mesos", "endpoint": "192.168.0.101", "host": "192.168.0.101", "allEndpoints": [{"host":"192.168.0.101"}, {"host":"192.168.0.102"}, {"host":"192.168.0.103"}], "took":"11"}

Advanced usage

If you want to query services which open more than one port (i.e. a specific port), you can use the options object of the get() to specify the portIndex property (starting with 0):

client.get("web.marathon.mesos", { portIndex: 1 }, function(error, addressInfo) {
    if (error) console.log(JSON.stringify(error));
    
    console.log("The complete addressInfo is: " + JSON.stringify(addressInfo));
    console.log("The endpoint is: " + JSON.stringify(addressInfo.endpoint));
    
});

In this case, the client would return the endpoints for the second port (per instance) which is opened by Marathon.