distributed-id-generator
Prefixed id generator over distributed services
Last updated 2 years ago by nanov .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install distributed-id-generator 
SYNC missed versions from official npm registry.

distributed-id-generator v0.5.2

System wide singleton distributed ID generator.

The library contains the following module groups :

  • Hashing algorithms ( Base32, node-fe1-fpe )
  • Checksum generation and validation ( Modified )
  • ID Generation and validation logic.
  • Guardstore implementation - Redis backend to ensure consistent distributed ID generation

Currently two types of IDs are supported, strictly numeric or base32 alpha-numeric ones.

Usage guidelines

To avoid id format errors and ensure consistency between system services all external usage of the library should be through the definitions found here, after configuring the guardstore.

Example :

	const path = require('path');
	const DistributedIdGenerator = require('distributed-id-generator');

	const idGenerator = DistributedIdGenerator.configureGuardstore({ // Redis optional settings
		host: 'localhost', // default
		port: 6379, // default
		db: 1, // default
		prefix: 'id-guard-store', // default
	}).loadDefinitions(path.join(process.cwd(), './app/ids/'));

Defining Ids :

	const { IdDefinition } = require('distributed-id-generator');

	// name, length including checksum, prefix, algorith either numeric or base32
	module.exports = new IdDefinition('account', 8, 'acc', 'base32');

Definition that is based on another :

	const accountIdDefinition = require('./account');

	// this will produce ids that are : cus-XXXXXXXX-XXXXXXXX
	module.exports = accountIdDefinition.extend('customer', 8, 'cus', 'base32');

Current Tags

  • 0.5.42                                ...           latest (2 years ago)

10 Versions

  • 0.5.42                                ...           2 years ago
  • 0.5.41                                ...           2 years ago
  • 0.5.4                                ...           2 years ago
  • 0.5.38                                ...           2 years ago
  • 0.5.37                                ...           2 years ago
  • 0.5.36                                ...           2 years ago
  • 0.5.35                                ...           2 years ago
  • 0.5.31                                ...           2 years ago
  • 0.5.3                                ...           2 years ago
  • 0.5.2                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 5
Dependencies (2)
Dev Dependencies (5)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |