1
0
mirror of synced 2026-04-18 14:28:43 +08:00

auto commit

This commit is contained in:
yitter
2021-04-01 10:31:00 +08:00
parent 6e1a47dc68
commit 29ec38cd07
5 changed files with 12 additions and 8 deletions

View File

@@ -23,7 +23,7 @@ func NextId() uint64 {
// 注册一个新的WorkerId
//export RegisterWorkerId
func RegisterWorkerId(ip *C.char, port int, password *C.char, maxWorkerId int) int {
return regworkerid.RegisterWorkerId(C.GoString(ip), port, C.GoString(password), maxWorkerId)
return int(regworkerid.RegisterWorkerId(C.GoString(ip), port, C.GoString(password), maxWorkerId))
}
// 注销WorkerId
@@ -32,9 +32,9 @@ func UnRegisterWorkerId() {
regworkerid.UnRegisterWorkerId()
}
// 检查本地WorkerId是否有效
// 检查本地WorkerId是否有效0-有效,其它-无效)
//export ValidateLocalWorkerId
func ValidateLocalWorkerId(workerId int) bool {
func ValidateLocalWorkerId(workerId int) int {
return regworkerid.ValidateLocalWorkerId(workerId)
}

View File

@@ -26,8 +26,12 @@ const _WorkerIdValueKeyPrefix string = "IdGen:WorkerId:Value:" // redis 中的ke
const _WorkerIdFlag = "Y" // IdGen:WorkerId:Value:xx 的值(将来可用 _token 替代)
const _Log = false // 是否输出日志
func ValidateLocalWorkerId(workerId int) bool {
return workerId == _usingWorkerId
func ValidateLocalWorkerId(workerId int) int {
if workerId == _usingWorkerId {
return 0
} else {
return -1
}
}
func UnRegisterWorkerId() {

Binary file not shown.

View File

@@ -75,8 +75,8 @@ extern __declspec(dllexport) GoInt RegisterWorkerId(char* ip, GoInt port, char*
// 注销WorkerId
extern __declspec(dllexport) void UnRegisterWorkerId();
// 检查本地WorkerId是否有效
extern __declspec(dllexport) GoUint8 ValidateLocalWorkerId(GoInt workerId);
// 检查本地WorkerId是否有效0-有效,其它-无效)
extern __declspec(dllexport) GoInt ValidateLocalWorkerId(GoInt workerId);
#ifdef __cplusplus
}

View File

@@ -168,7 +168,7 @@ ID示例基于默认配置
#### 自动注册WorkerId
本算法提供一个开源的动态库go实现能在容器k8s环境下通过 redis 自动注册 WorkerId。动态库提供的C接口方法有
本算法提供一个开源的动态库go语言实现),能在容器 k8s(或其它容器化集群) 环境下,通过 redis 自动注册 WorkerId。动态库提供的C接口方法有
```
// 注册一个新的WorkerId