ynn-ms-idalloc
Ynn micro-service module for ID allocation. Supported FlakeID and UUID.
Last updated a year ago by ynn .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install ynn-ms-idalloc 
SYNC missed versions from official npm registry.

ynn-ms-idalloc

Ynn micro-service module for ID allocation. Supported FlakeID and UUID.

Build Status Coverage Status Node Version License NPM Version NPM Download

Installation

$ npm install ynn-ms-idalloc --save

Usage

Starting as a indenpent service

$ npx ynn-ms-idalloc --port=3000

Using as a module

const Ynn = require( 'ynn' );
const app = new Ynn( {
    root : __dirname,
    modules : {
        id : {
            path : 'ynn-ms-idalloc',
            config : { }
        }
    }
} );

Configuration items

flake Object

  • datacenter (5 bit) - datacenter identifier. It can have values from 0 to 31.
  • worker (5 bit) - worker identifier. It can have values from 0 to 31.
  • id (10 bit) - gnerator identifier. It can have values from 0 to 1023. It can be provided instead of datacenter and worker identifiers.
  • epoch - number used to reduce value of a generated timestamp. Note that this number should not exceed number of milliseconds elapsed since 1 January 1970 00:00:00 UTC. It can be used to generate smaller ids.

Generating SnowFlake ID is using https://github.com/T-PWK/flake-idgen package.

API

/flake

To generate a SnowFlake ID.

/uuid/v1

To generate UUID version 1

/uuid/v3?name={name}&namespace={namespace}

To generate UUID version 3

/uuid/v4

To generate UUID version 4

/uuid/v5?name={name}&namespace={namespace}

Note: While generating UUID v3 and v5, the namespace can be a pre-defined namespace name in [ dns, url, oid, x500 ] defind in RFC4122. For example:

/uuid/v5?name={name}&namespace=url

To generate UUID version 5

Current Tags

  • 0.0.4                                ...           latest (a year ago)

5 Versions

  • 0.0.4                                ...           a year ago
  • 0.0.3                                ...           2 years ago
  • 0.0.2                                ...           2 years ago
  • 0.0.1                                ...           2 years ago
  • 0.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 1
Last Month 1
Dependencies (4)
Dev Dependencies (6)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |