diff --git a/C#.NET/README.md b/C#.NET/README.md index 4779926..33834f0 100644 --- a/C#.NET/README.md +++ b/C#.NET/README.md @@ -1,9 +1,9 @@ - + ## 运行环境 .NET Standard 2.0+ -## 引用nuget包 +## 引用 nuget 包 ``` ``` diff --git a/C/README.md b/C/README.md index 8dcff92..032b153 100644 --- a/C/README.md +++ b/C/README.md @@ -1,4 +1,4 @@ -# idgenerator +# idgenerator ## 编译说明 diff --git a/Go/README.md b/Go/README.md index 1bff156..44ec2fd 100644 --- a/Go/README.md +++ b/Go/README.md @@ -1,21 +1,9 @@ -# ❄ 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 + diff --git a/Java/README.md b/Java/README.md index e045fe5..d4e41af 100644 --- a/Java/README.md +++ b/Java/README.md @@ -1,4 +1,4 @@ - + ## 运行环境 JDK 1.8+ diff --git a/Rust/README.md b/Rust/README.md index 01ddc83..2767343 100644 --- a/Rust/README.md +++ b/Rust/README.md @@ -1,22 +1,22 @@ -# 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 的最大值)。 -// IJöЧ +// 保存参数(必须的操作,否则以上设置都不能生效): YitIdHelper::SetIdGenerator(options); -// ϳʼֻȫһΣұڵ2֮ǰá +// 以上初始化过程只需全局一次,且必须在第2步之前设置。 ``` -2ID +第2步,生成ID: ``` -// ʼԺ󣬼κҪIDĵط· +// 初始化以后,即可在任何需要生成ID的地方,调用以下方法: long newId = YitIdHelper::NextId(); ``` diff --git a/Rust/source/Cargo.lock b/Rust/source/Cargo.lock index 33c508a..f009ef2 100644 --- a/Rust/source/Cargo.lock +++ b/Rust/source/Cargo.lock @@ -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", diff --git a/Rust/source/Cargo.toml b/Rust/source/Cargo.toml index 64350e1..836f386 100644 --- a/Rust/source/Cargo.toml +++ b/Rust/source/Cargo.toml @@ -1,8 +1,15 @@ [package] -name = "yitidgen" +name = "yiter-idgenerator" version = "1.0.0" authors = ["yitter "] 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" diff --git a/Rust/source/README.md b/Rust/source/README.md new file mode 100644 index 0000000..2767343 --- /dev/null +++ b/Rust/source/README.md @@ -0,0 +1,23 @@ +# 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(); +``` + + diff --git a/Rust/source/src/lib.rs b/Rust/source/src/lib.rs index 63a664e..1e4274b 100644 --- a/Rust/source/src/lib.rs +++ b/Rust/source/src/lib.rs @@ -14,17 +14,17 @@ use libc::{c_char, uint32_t}; use std::ffi::{CStr, CString}; use std::str; -lazy_static! { - //static ref TestValue: Vec = vec!(0); - // static ref MAP: HashMap = HashMap::new(); - } +// lazy_static! { +// static ref TestValue: Vec = vec!(0); +// static ref MAP: HashMap = 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) {