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

now-fleet

v3.0.9

Published

Helps with multiple microservice deployments

Downloads

25

Readme

now-fleet

Build Status js-standard-style npm version Coverage Status

An api to make it easy to deploy complete infrastructures of microservices using now

Installing

npm install now-fleet --save

Service Dependency

We define service dependencies in package.json of each service. Let's say we have a service A depending on service B and C, package.json for A should have a services field as following:

{
  "services": {
    "serviceB": "^2.0.0",
    "serviceC": "^3.0.0"
  }
}

Let's say B also depends on C. Then package.json for B should have a services field as following:

{
  "services": {
    "serviceC": "^2.0.0"
  }
}

Service dependencies need a version like npm module dependencies. This version should be a published version of npm module for dependency service. For our example, service A depends on ^3.0.0 of C but service B depends on ^2.0.0 of C.

Fleet Deployment

We start deployment from the topmost service which depends on other services, for our example service A. Let's call it root service.

export NOW_TOKEN="YOUR-NOW-API-TOKEN"
export REGISTRY_HOST="registery.host.sh"
node_modules/.bin/now-fleet-deploy type=ENV_TYPE

This script walks through all the services we depend on and dependencies of them recursively. Deploys them to now and gives us now url of root service.

Root Service Decision

Deployment script should run on a service considering dependency tree. It can only walk down from top and can't discover dependants magically. If there is a service in the stack which is not a dependency of any other service, it won't be discovered and should be deployed separately.

Circular Dependency

Circular dependencies are taken care at deployment time and all fine. A can depend on B and B can depend on A at the same time or while A depends on B and B depends on C; C can depend on A.

Limitations

Another version of root service can't be a dependency of any service in the tree. For example [email protected] is deployment root and depends on, service B and service C. This schema allows service B or C depending on [email protected] but not on [email protected].

Service Discovery

Each service should discover dependency urls on the boot time. This module provides a method for discovery.

getServices(pkg, delay)

Discovers host names of dependencies defined in package.json by polling the latest deployed services from now API. Takes care of finding the host name for the right version of the dependency service. Second parameter is the delay in miliseconds between each polling from now API. It'll repeat until discovering all the deployments.

const fleet = require('now-fleet').fleet

const pkg = require('./package.json')

fleet.getServices(pkg, 2000)
  .then(pkg => {
    // pkg._services object has all the host names
    // pkg._services.serviceC is something like url-sdfsd.now.sh
  })