https://github.com/brainpoint/febs-identify-java
Distributed unique identify like ObjectId
https://github.com/brainpoint/febs-identify-java
distributed-id-generator distributed-identity febs java objectid
Last synced: 11 months ago
JSON representation
Distributed unique identify like ObjectId
- Host: GitHub
- URL: https://github.com/brainpoint/febs-identify-java
- Owner: brainpoint
- License: mit
- Created: 2020-07-02T15:03:37.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-06-21T03:47:26.000Z (over 3 years ago)
- Last Synced: 2024-12-30T07:11:50.675Z (about 1 year ago)
- Topics: distributed-id-generator, distributed-identity, febs, java, objectid
- Language: Java
- Homepage:
- Size: 23.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Febs-identify
[](https://maven-badges.herokuapp.com/maven-central/cn.brainpoint/febs-identify/)
[](https://opensource.org/licenses/MIT)
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.
```html
cn.brainpoint
febs-identify
0.0.5
```
Generate the ID using the following code:
```java
import cn.brainpoint.febs.identify.*;
String uniqueId = Identify.nextId();
```
### Initialize
```java
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
```java
String id = Identify.nextId();
```
### Valid Id
```java
assert Identify.isValid(id);
```