From 46328d9eae752f5e3173e5000187b5692f8492dd Mon Sep 17 00:00:00 2001 From: yitter Date: Mon, 5 Apr 2021 23:26:12 +0800 Subject: [PATCH] auto commit --- C#.NET/README.md | 4 ++-- C/README.md | 2 +- Go/README.md | 29 +++++++++++++++-------------- Java/README.md | 2 +- Rust/README.md | 20 ++++++++++---------- Rust/source/Cargo.lock | 2 +- Rust/source/Cargo.toml | 11 +++++++++-- Rust/source/README.md | 23 +++++++++++++++++++++++ Rust/source/src/lib.rs | 18 +++++++++--------- 9 files changed, 71 insertions(+), 40 deletions(-) create mode 100644 Rust/source/README.md 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 的最大值)。 -// ±£´æ²ÎÊý£¨±ØÐëµÄ²Ù×÷£¬·ñÔòÒÔÉÏÉèÖö¼²»ÄÜÉúЧ£©£º +// ä¿�å­˜å�‚数(必须的æ“�作,å�¦åˆ™ä»¥ä¸Šè®¾ç½®éƒ½ä¸�能生效): YitIdHelper::SetIdGenerator(options); -// ÒÔÉϳõʼ»¯¹ý³ÌÖ»ÐèÈ«¾ÖÒ»´Î£¬ÇÒ±ØÐëÔÚµÚ2²½Ö®Ç°ÉèÖᣠ+// 以上åˆ�始化过程å�ªéœ€å…¨å±€ä¸€æ¬¡ï¼Œä¸”必须在第2步之å‰�设置。 ``` -µÚ2²½£¬Éú³ÉID£º +第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) {