0.5.43 • Published 5 years ago

distributed-id-generator v0.5.43

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

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');
0.5.43

5 years ago

0.5.42

5 years ago

0.5.41

5 years ago

0.5.4

5 years ago

0.5.38

6 years ago

0.5.37

6 years ago

0.5.36

6 years ago

0.5.35

6 years ago

0.5.31

6 years ago

0.5.3

6 years ago

0.5.2

6 years ago