Giter VIP home page Giter VIP logo

fintx-identifier's Introduction

FinTx Identifier Generator

Maven Central GitHub release Apache 2 Join the chat at https://gitter.im/fintx/fintx-identifier Build Status Coverage Status Dependency Status

FinTx[1]

What's is FinTx?

FinTx is an open source group focus on financial technologies.

What's is fintx-identifier

fintx-identifier is for generating unique id in high performance and distribution environment. It extends the mongodb's ObjectId that using full MAC address to prevent the duplicated Id. It does not depend on the seeds like snowflake id generator. It can generate both 20 charachers base64 URL safe id (recommend) and 30 characters hex character id. Both id characters are in sequence that not random.

Structure

Consists of 15 bytes, divided as follows:

UniqueId layout
01234567891011121314
timemachinepidcounter

Limitations

  1. ProcessId on os could not bigger then 65535 (the default max value in most linux OS).
  2. Only in one bundle of same JVM when using OSGI.
  3. Id requirement could not more then about 16777215 per second per JVM.
  4. Maybe it will generate duplicated id every 69 years.

Using

This is something that you get for free just by adding the following dependency inside your project:

<dependency>
    <groupId>org.fintx</groupId>
    <artifactId>fintx-identifer</artifactId>
    <version>${latest.version></version>
</dependency>

Example

  1. Get a 20 characters length unique id.
String id = UniqueId.get().toBase64String();
  1. Parse id to get timestamp, machine identifier (physical MAC address), process identifier, counter number.
UniqueId uniqueId = UniqueId.fromBase64String(id);    
long timestamp = uniqueId.getTimestamp();    
long machineId = uniqueId.getMachineIdentifier();    
int processId = uniqueId.getProcessIdentifier();    
long counter = uniqueId.getCounter();    

[1] FinTx https://www.fintx.org/
[2] Maven https://maven.apache.org/

fintx-identifier's People

Contributors

bluecreator avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.