egg-snowflake-js
snowflake plugin for egg
Last updated 5 months ago by biubiukevin .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install egg-snowflake-js 
SYNC missed versions from official npm registry.

egg-snowflake-js

NPM version build status Test coverage David deps Known Vulnerabilities npm download

Install

$ npm i egg-snowflake-js --save

Dependencies egg version

egg-snowflake-js version egg 1.x
1.x ????

Usage

// {app_root}/config/plugin.js
exports.snowflake = {
  enable: true,
  package: 'egg-snowflake-js',
};

Configuration

// {app_root}/config/config.default.js
exports.snowflake = {
  client: {
    workerId: 1,    //1 to 31 int number. If do not set workerId, it will set a random number from 1 to 31
    machineId: 1    //1 to 31 int number. If do not set machineId, it will set a int number(1 to 31) from hostname lenth
  }
};

see config/config.default.js for more detail.

Example

//{app_root}/app/controller/index.js
async index() {
  const app = this.app;
  const flakeId = app.snowflake.next();
  console.log(flakeId)
}

Questions & Suggestions

Please open an issue here.

License

MIT

Current Tags

  • 1.1.3                                ...           latest (2 months ago)

5 Versions

  • 1.1.3                                ...           2 months ago
  • 1.1.2                                ...           5 months ago
  • 1.1.1                                ...           5 months ago
  • 1.1.0                                ...           5 months ago
  • 1.0.0                                ...           5 months ago
Maintainers (1)
Downloads
Today 7
This Week 26
This Month 100
Last Day 5
Last Week 24
Last Month 94
Dependencies (5)
Dev Dependencies (8)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |