febs-identify

Distributed Unique Identify like ObjectId.

License

License

Categories

Categories

IDE Development Tools
GroupId

GroupId

cn.brainpoint
ArtifactId

ArtifactId

febs-identify
Last Version

Last Version

0.0.5
Release Date

Release Date

Type

Type

jar
Description

Description

febs-identify
Distributed Unique Identify like ObjectId.
Project URL

Project URL

https://github.com/brainpoint/febs-identify-java.git
Source Code Management

Source Code Management

https://github.com/brainpoint/febs-identify-java.git

Download febs-identify

How to add to project

<!-- https://jarcasting.com/artifacts/cn.brainpoint/febs-identify/ -->
<dependency>
    <groupId>cn.brainpoint</groupId>
    <artifactId>febs-identify</artifactId>
    <version>0.0.5</version>
</dependency>
// https://jarcasting.com/artifacts/cn.brainpoint/febs-identify/
implementation 'cn.brainpoint:febs-identify:0.0.5'
// https://jarcasting.com/artifacts/cn.brainpoint/febs-identify/
implementation ("cn.brainpoint:febs-identify:0.0.5")
'cn.brainpoint:febs-identify:jar:0.0.5'
<dependency org="cn.brainpoint" name="febs-identify" rev="0.0.5">
  <artifact name="febs-identify" type="jar" />
</dependency>
@Grapes(
@Grab(group='cn.brainpoint', module='febs-identify', version='0.0.5')
)
libraryDependencies += "cn.brainpoint" % "febs-identify" % "0.0.5"
[cn.brainpoint/febs-identify "0.0.5"]

Dependencies

compile (2)

Group / Artifact Type Version
org.mybatis : mybatis jar 3.5.5
mysql : mysql-connector-java jar 8.0.20

provided (2)

Group / Artifact Type Version
org.projectlombok : lombok jar 1.18.12
org.slf4j : slf4j-api jar 1.7.30

Project Modules

There are no modules declared in this project.

Febs-identify

Maven Central License

Distributed Unique Identify.

  • like objectId, a process can generator id 2^24-1 per second.
  • Container 20 chars in id
  • Use database to assign unique machineId.

How to use

maven config.

<dependency>
    <groupId>cn.brainpoint</groupId>
    <artifactId>febs-identify</artifactId>
    <version>0.0.5</version>
</dependency>

Generate the ID using the following code:

import cn.brainpoint.febs.identify.*;

String uniqueId = Identify.nextId();

Initialize

import cn.brainpoint.febs.identify.*;

Identify.initialize(new IdentifyCfg(
    "mysql",
    "localhost:3306/xx",
    "username",
    "password",
));

Use database to assign unique machineId. It will use '_distribute_machineId' to named table if not specify a table name.

This method can be invoked multiple times in response to dynamic changes to the application configuration.

Generate a New Id

String id = Identify.nextId();

Valid Id

assert Identify.isValid(id);

Versions

Version
0.0.5
0.0.4
0.0.3
0.0.2
0.0.1