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

@infect/rda-service-registry-client

v2.3.5

Published

RDA Service Registry Client

Downloads

23

Readme

RDA Service Registry Client

The RDA registry client provides facilities for registering & looking up services at the RDA service registry.

API

Registering as service

The client can be used to register as a service that can be consumed by other services.

import ServiceRegistryClient from '@infect/rda-service-registry-client';

// pass the service registry host to the client
const client = new ServiceRegistryClient('http://localhost:8000');

// register the service
await client.register({
    serviceName: 'test-service',
    port: 7891,
});

// de-register again
await client.deregister();

Looking up a service

The client can be used to lookup where to find other services. If one service was registered multiple times at the registry a random one will be returned.

import ServiceRegistryClient from '@infect/rda-service-registry-client';

// pass the service registry host to the client
const client = new ServiceRegistryClient('http://localhost:8000');

// get the address of one random serviceName service instance
const url = await client.lookup(serviceName);

Constructor

The registry client the address under which the registry service is reachable. Thats the only parameter that needs to be passed to it.

Attention: if you are registering yourself as service you must only use one instance of the registry client since it creates a identifier by which it is later identified. If you wish to use multiple instances you need to pass the identifier to to the register method each time it is used.

const client = new ServiceRegistryClient('http://localhost:8000');

client.register()

Register your service on the registry service so that it can be consumed by other services. This method should only be called once per service on one client instance (see the warning in the Constructor documentation).

Parameters:

  • serviceName: the name of your service
  • port: the port your service is listening on
  • identifier: optional: a unique identifier for your instance of the service
  • protocol: the protocol used to contact your service. defaults to http://
await client.register({
    serviceName: 'test-service',
    port: 7891,
    identifer: myidentifier,
    protocol: 'http://'
});

client.deregister()

De-register your service so that other services will not try to contact it again.

await client.deregister();

client.resolve()

Look up the address of another service. If multiple instances of the other service are available the address of a random one will be returned.

const url = await client.lookup(serviceName);