提交 46328d9e 编写于 作者: yitter's avatar yitter

auto commit

上级 012d9983

## 运行环境
.NET Standard 2.0+
## 引用nuget
## 引用 nuget
```
<PackageReference Include="Yitter.IdGenerator" Version="1.0.*" />
```
......
# idgenerator
# idgenerator
## 编译说明
......
# ❄ idenerator-go
# ❄ idenerator-go
## 介绍
项目更多介绍参照:https://github.com/yitter/idgenerator
## Go环境
1.SDK,go1.14
2.启用 Go-Modules
```
go env -w GO111MODULE=on
# Next *ONLY* for China-Users:
go env -w GOPROXY=https://goproxy.cn,https://goproxy.io,direct
```
3. 安装方式
## 引用全局库
```
go get -u -v github.com/yitter/idgenerator-go
```
......@@ -40,5 +28,18 @@ idgen.SetIdGenerator(options)
var newId = idgen.NextId()
```
## 关于Go环境
1.SDK,go1.14
2.启用 Go-Modules
```
go env -w GO111MODULE=on
# Next *ONLY* for China-Users:
go env -w GOPROXY=https://goproxy.cn,https://goproxy.io,direct
```
## 代码贡献者(按时间顺序)
guoyahao | amuluowin | houseme

## 运行环境
JDK 1.8+
......
# idgenerator
# idgenerator
## 调用示例(Rust)
## 调用示例(Rust)
第1步,**全局** 初始化(应用程序启动时执行一次):
第1步,**全局** 初始化(应用程序启动时执行一次):
```
// 创建 IdGeneratorOptions 对象,请在构造函数中输入 WorkerId:
// 创建 IdGeneratorOptions 对象,请在构造函数中输入 WorkerId:
let mut options = IdGeneratorOptions::New(1);
// options.WorkerIdBitLength = 10; // WorkerIdBitLength 默认值6,支持的 WorkerId 最大值为2^6-1,若 WorkerId 超过64,可设置更大的 WorkerIdBitLength
// ...... 其它参数设置参考 IdGeneratorOptions 定义,一般来说,只要再设置 WorkerIdBitLength (决定 WorkerId 的最大值)。
// options.WorkerIdBitLength = 10; // WorkerIdBitLength 默认值6,支持的 WorkerId 最大值为2^6-1,若 WorkerId 超过64,可设置更大的 WorkerIdBitLength
// ...... 其它参数设置参考 IdGeneratorOptions 定义,一般来说,只要再设置 WorkerIdBitLength (决定 WorkerId 的最大值)。
// 保存参数(必须的操作,否则以上设置都不能生效):
// 保存参数(必须的操作,否则以上设置都不能生效):
YitIdHelper::SetIdGenerator(options);
// 以上初始化过程只需全局一次,且必须在第2步之前设置。
// 以上初始化过程只需全局一次,且必须在第2步之前设置。
```
第2步,生成ID:
第2步,生成ID:
```
// 初始化以后,即可在任何需要生成ID的地方,调用以下方法:
// 初始化以后,即可在任何需要生成ID的地方,调用以下方法:
long newId = YitIdHelper::NextId();
```
......
......@@ -269,7 +269,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "yitidgen"
name = "yiter-idgenerator"
version = "1.0.0"
dependencies = [
"chrono",
......
[package]
name = "yitidgen"
name = "yiter-idgenerator"
version = "1.0.0"
authors = ["yitter <yitter@126.com>"]
edition = "2018"
license = "MIT"
description="Shorter ID and faster generation with a new snowflake drift algorithm. The core is to shorten the ID length, but also can have a very high instantaneous concurrent processing capacity (50W/0.1s), and powerful configuration capacity."
readme = "README.md"
homepage ="https://github.com/yitter/IdGenerator"
repository = "https://github.com/yitter/IdGenerator"
keywords = ["snowflake", "idgenerator"]
#categories = ["command-line-utilities"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
......@@ -11,7 +18,7 @@ chrono = "0.4.10"
lazy_static = "1.4.0"
#simple_redis = "*"
redis = "0.20.0"
libc="*"
libc = "*"
#actix = "0.9.0"
#actix-web = "2.0"
......
# idgenerator
## 调用示例(Rust)
第1步,**全局** 初始化(应用程序启动时执行一次):
```
// 创建 IdGeneratorOptions 对象,请在构造函数中输入 WorkerId:
let mut options = IdGeneratorOptions::New(1);
// options.WorkerIdBitLength = 10; // WorkerIdBitLength 默认值6,支持的 WorkerId 最大值为2^6-1,若 WorkerId 超过64,可设置更大的 WorkerIdBitLength
// ...... 其它参数设置参考 IdGeneratorOptions 定义,一般来说,只要再设置 WorkerIdBitLength (决定 WorkerId 的最大值)。
// 保存参数(必须的操作,否则以上设置都不能生效):
YitIdHelper::SetIdGenerator(options);
// 以上初始化过程只需全局一次,且必须在第2步之前设置。
```
第2步,生成ID:
```
// 初始化以后,即可在任何需要生成ID的地方,调用以下方法:
long newId = YitIdHelper::NextId();
```
......@@ -14,17 +14,17 @@ use libc::{c_char, uint32_t};
use std::ffi::{CStr, CString};
use std::str;
lazy_static! {
//static ref TestValue: Vec<i32> = vec!(0);
// static ref MAP: HashMap<u32, String> = HashMap::new();
}
// lazy_static! {
// static ref TestValue: Vec<i32> = vec!(0);
// static ref MAP: HashMap<u32, String> = HashMap::new();
// }
// // #[export_name = "SetIdGenerator"]
// #[no_mangle]
// pub extern "C" fn SetIdGenerator(options: IdGeneratorOptions) {
// YitIdHelper::SetIdGenerator(options);
// }
// #[export_name = "SetIdGenerator"]
#[no_mangle]
pub extern "C" fn SetIdGenerator(options: IdGeneratorOptions) {
YitIdHelper::SetIdGenerator(options);
}
#[no_mangle]
pub extern "C" fn SetOptions(workerId: u32, workerIdBitLength: u8, seqBitLength: u8) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册