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

thalassa-http-client

v0.1.0

Published

A simple http client for Thalassa that doesn't require ZeroMQ

Downloads

6

Readme

Thalassa Client

A lightweight client for Thalassa

Running the Client

The client can be run any of three ways.

  1. From the command-line
  2. As a module
  3. Over HTTP

Running Client from Command Line

Why would you do this? Let's say you have an existing legacy Java application that you'd rather not change. You can create a sister service that invokes the command line client to register the service on it's behalf.

For example, if Thalassa is installed globally (other wise `./node_modules/.bin/thalassa-client):

thalassa-client --register [email protected]:8080 --debug

This registers the application named my app at version 1.0.0 that's on the current host on port 8080. The client will continue to ping the Thalassa server with updates.

Client Command Line Options

thalassa-client --help
  Options:
    --host           thalassa host                                                    [default: "127.0.0.1"]
    --apiport        thalassa http api port                                           [default: 9000]
    --register       [email protected]:port,[email protected]:port                                  [required]
    --secsToExpire   default time in seconds for a thalassa registration to be valid  [default: 60]
    --updateFreq     time frequency in ms to ping the thalassa server                 [default: 20000]
    --updateTimeout  time in ms to wait for a registration request to respond         [default: 2500]
    --debug          enabled debug logging

Client as an Embedded Module

Using the client from within a node.js application to register your service is simple. Pass options via the opts object like new Thalassa.Client(opts):

var Thalassa = require('thalassa');

var client = new Thalassa.Client({
  apiport: 4445,
  host: 'localhost'
});

client.register('myapp', '1.0.0', 8080);

// start reporting registrations to the server
client.start();

// stop reporting registrations to the server
client.stop();

opts.log may be passed just like the server.

updateSuccessful and updateFailed Events

The client will periodically check in with the Thalassa server according to opts.updateFreq (default 5000ms). Each registration will product a updateSuccessful or updateFailed event to be emitted.

client.on('updateSuccessful', function () {}); client.on('updateFailed', function (error) {});

Querying Registrations

Also as a module, you can use the client API to query for registrations.

client.getRegistrations('myapp', '1.0.0', function (err, registrations) {
    // registrations is an Array of Registrations
}

See the HTTP API section for the Registration structure.

Metadata

You can also pass metadata with any registration as a fourth parameter. This can be any javascript object with properties. For example:

var meta = {
    az: 'use1a',
    size: 'm1.large',
    foo: {
        bar: 'baz'
    }
};
client.register('myapp', '1.0.0', 8080, meta)

License

Licensed under Apache 2.0. See LICENSE file.