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

sarathi-consul-strategy

v0.0.6

Published

Implementation of Sarathi's discovery API for Consul.io Edit

Downloads

17

Readme

sarathi-consul-strategy

Implementation of Sarathi's discovery API for Consul.io

Build Status Coverage Status

Installation

npm install sarathi-consul-strategy --save

Features

Lets you use Sarathi as declarative rest client with client-side load balancing when using consul.io discovery server.

Usage

var ConsulDiscoveryStrategy = require("sarathi-consul-strategy").DiscoveryStrategy;
var ds = new ConsulDiscoveryStrategy(...);
sarathiClientBuilder.setDiscoveryStrategy(ds);

Options

  • serviceId: String name of the service to discover, Ex: "testservice"
  • client: Object instance of discovery service client, if you already have one; you might have used it for registering your service.
  • clientConfig: Object Configuration to be passed to discovery service client, if you want sarathi to instantiate it. Client instance, if passed, takes precedence over this.
  • refreshRate: Number in ms. timeout, to refresh discovered services. Ex: 30000 to mean every 30s.
  • zone: String not yet supported, but for data-center awareness.
  • discoveryTimeout: Number in ms. Timeout, time to wait for before the call to the discovery server times out.

Examples

When consul server is running locally

var ds = new ConsulDiscoveryStrategy({serviceId: "express-service"});

When consul client already instantiated

var ds = new ConsulDiscoveryStrategy({serviceId: "express-service", client: consulClientInstance});

API

A fluent API for setting configuration

DiscoveryBuilder()

Object returned by require("sarathi-consul-strategy").StrategyBuilder

#setClient(discoveryClient)

Set instance of the discovery server client. This shall come handy when you have already instantiated the client instance for registering with the server.

#setClientConfig(clientConfig)

Pass the config for sarathi to instantiate the client. If setClient and setClientConfig both are used, client instance passed will be used and the configuration provided to this method will be discarded. You can un-set the client instance by setting it to undefined.

#setRefreshRate(refreshRate)

Set service catalg refresh timeout

#setServiceId(serviceId)

Set the service name to look for on the discovery server

#setZone(zone)

NOT Implemented; but this is where you can set the data center preference

#setDiscoveryTimeout(timeout)

Sets the timeout period for throwing exception for when discovery server is taking too long to respond.

#build()

Builds the discovery handler instance and returns the instance of DiscoveryStrategy.

ConsulDiscoveryStrategy

Sarathi consul discovery strategy

#getConsulInstance()

Returns the instance of consul client, if you needed to use it.

Configuration Defaults

{
	serviceId: undefined,
	client: undefined,
	clientConfig: {},
	refreshRate: 30000,
	zone: undefined,
	discoveryTimeout: 30000
}