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

aws-latency-check

v1.0.0

Published

Checks the latency to various AWS endpoints.

Downloads

4

Readme

#AWS Latency Check

This module will take an object of AWS endpoints and run a check against each to find the closest one.

Valid Services Endpoints

This check will run against the /ping endpoint for the AWS service endpoints provided. For this reason not all AWS services are valid. Valid services include:

  • EC2
  • SNS
  • SQS
  • SimpleDB

Methods

constructor(regions [, options])

Used to create an instance of the object.

Arguments

  • regions: This whould be an object of each region to check. Key should be the region_id and the value should be the hostname of the region to check. Each region must have a reachable endpoint of http://[hostname]/ping.
  • options: Various options for the test.
    • timeout: The max amount of time that can be passed when checking any one region. This defaults to 4000.

begin()

Called to actually begin the process. After a check has been completed if you wish to re-check you can call this method again.

Emitted Events

check_complete

Fired after the entire check is completed.

Sample Usage

checker.on('complete', function (results) {
    console.log(results);
});

Arguments

  • results: An array of each region results (ordered by lowest latency).

Example

[ 
	{ region: 'us-east-1', latency: 123 },
  	{ region: 'us-west-1', latency: 187 },
  	{ region: 'us-west-2', latency: 198 },
  	{ region: 'eu-central-1', latency: 293 },
  	{ region: 'ap-northeast-1', latency: 385 },
  	{ region: 'sa-east-1', latency: 406 },
  	{ region: 'ap-southeast-1', latency: 515 },
  	{ region: 'ap-southeast-2', latency: 754 },
  	{ region: 'eu-west-1', latency: null } 
]

region_complete

After a region is complete.

Sample Usage

checker.on('region_results', function (progress, results) {
    console.log(results);
});

Arguments

  • progress: The total percentage completed for the test. This can be used to update a progress bar etc.
  • results: Object of the region results.

Example

{ region: 'us-west-1', latency: 162 },

error

If an error was thrown and the test is stopped.

Sample Usage

checker.on('error', function (err) {
    console.log(err);
});

Arguments

  • err: The actual error message.

Data Model

Region Results

  • region: The region that was tested.
  • latency: The calculated latency. If there was an error this will be null.

Example

{ region: 'us-west-1', latency: 162, status_code: 200 }

Example Usage

// Require the library
var LatencyCheck = require('LatencyCheck');

// Define the regions to check.
var regions = {
	"us-east-1": "ec2.us-east-1.amazonaws.com",
	"us-west-1": "ec2.us-west-1.amazonaws.com",
	"ap-southeast-1": "ec2.ap-southeast-1.amazonaws.com",
	"us-west-2": "ec2.us-west-2.amazonaws.com",
	"sa-east-1": "ec2.sa-east-1.amazonaws.com",
	"eu-central-1": "ec2.eu-central-1.amazonaws.com",
	"eu-west-1": "ec2.eu-west-1.amazonaws.com",
	"ap-northeast-1": "ec2.ap-northeast-1.amazonaws.com",
	"ap-southeast-2": "ec2.ap-southeast-2.amazonaws.com"
};

// Create an instance of the object
var checker = new LatencyCheck(regions);

// Call the begin function
checker.begin();

// Listen for the check to complete.
checker.on('check_complete', function (results) {
    console.log(results);
});

// Listen for each region check to complete.
checker.on('region_complete', function (progress, results) {
    console.log('Current porogress': progress + '% complete');
    console.log(results);
});

// Listen for any errors so we can take the appropriate action
checker.on('error', function (err) {
    console.log(err);
});