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

idserver

v0.2.1

Published

A sequential ID generation server

Downloads

6

Readme

idserver: A sequential ID generation server

idserver is a node.js centralized sequential ID server for helping distributed applications getting unique and sequential IDs for their entities.

Installing

npm install idserver

Running a server

Running an idserver daemon:

node node_modules/idserver/bin/server.js

Server options:

The default server (bin/server.js) shipped with idserver has no configurations - everything is on default.

Server() constructor supports the following options:

  • port : TCP port number where the server should listen on; Defaults to 1970;

  • address : The network address where the server should listen on; Defaults to 127.0.0.1;

  • journaling : Enables or disables the journaling supports; Defaults to true;

  • journalFile : File path for storing the journaling data; Defaults to /tmp/idserver.journal;

  • dataFile : File path to be used for storing data (when using the internal storage system); Defaults to /tmp/idserver.data;

  • commitInterval : The interval of time between commits (or sets); Defaults to 1000 ms;

  • getter : Function to be used for getting the last ID for a key. The function arguments are (key,callback). Defaults to an internal dumb method. If a getter and a setter or a getter and a committer are specified, the internal storage system is disabled;

  • setter : Function to be used for storing the last ID for a key. The function arguments are (key,value,callback). Defaults to an internal dumb method; If a getter and a setter or a getter and a committer are specified, the internal storage system is disabled;

  • committer : The same as setter but for storing a set of keys and values at the same time. If a committer function is specified, setter is not used. Defaults to an internal commit function; If a getter and a setter or a getter and a committer are specified, the internal storage system is disabled;

  • idPattern : The pattern for the resulting IDs or null. Something like 'CLIENT-%%%-###' where '#' means a digit and '%' a letter between 'A' and 'Z'; Defaults to null - meaning a regular integer (between 1 and the biggest supported integer);

  • keyOptions : An object containing the options to be used for a specific key; The supported options are: idPattern;

  • DEBUG : Activates or deactivates the debugging mode; Defaults to false.

Running a client and asking for ids:

var
    IDClient = require('idserver').Client,
    client = new IDClient({host: "127.0.0.1"});

client.ask("x",10,function(err,ids){
    if ( err ) {
        console.log("Error getting IDs: ",err);
        throw err;
    }

    console.log("Got IDs: ",ids);
});

Client() constructor supports the following options:

  • host : The network address of the server; Defaults to 127.0.0.1;

  • port : The TCP port number of the server; Defaults to 1970;

  • MAXRETRIES : Maximum number of connect retries; Defaults to null - meaning infinite number of retries;

  • DEBUG : Activates or deactivates de debugging mode; Defaults to false.

A Client instance supports the following methods:

  • ask('KEY',NUMBER_OF_IDS,callback) - Ask for a specific number of IDs (optional - defaults to 1) for a key (required).
  • last('KEY',callback) - Get the last ID for a key (required).

Bugs and stuff

Mail me or make a Github issue request.