1
0
mirror of synced 2026-02-25 22:37:59 +08:00

auto commit

This commit is contained in:
yitter
2021-04-04 13:23:52 +08:00
parent 0e2b520268
commit 72cef35e4d
2 changed files with 13 additions and 21 deletions

View File

@@ -170,21 +170,8 @@ SeqBitLength = 6
🔍 唯一ID生成器依赖WorkerId当业务服务需要水平自动化复制时就要求它能自动化注册全局唯一WorkerId然后各个容器化的无差别部署的业务服务才能根据它生产唯一ID。
🔍 本算法提供一个开源的动态库go语言实现能在容器 k8s或其它容器化集群 环境下,通过 redis 自动注册 WorkerId。动态库提供的C接口方法有:
```
// 注册一个 WorkerId会先注销所有本机已注册的记录
extern __declspec(dllexport) GoInt32 RegisterOne(char* ip, GoInt32 port, char* password, GoInt32 maxWorkerId);
// 注册多个 WorkerId会先注销所有本机已注册的记录
extern __declspec(dllexport) int* RegisterMany(char* ip, GoInt32 port, char* password, GoInt32 maxWorkerId, GoInt32 totalCount);
// 注销本机已注册的 WorkerId
extern __declspec(dllexport) void UnRegister();
// 检查本地WorkerId是否有效0-有效,其它-无效)
extern __declspec(dllexport) GoInt32 Validate(GoInt32 workerId);
```
🔍 本算法提供一个开源的动态库go语言实现能在容器 k8s或其它容器化集群 环境下,通过 redis 自动注册 WorkerId。动态库提供的C接口方法可参考
源码文件 [ Tools/AutoRegisterWorkerId/lib/yitidgengo.h ]
redis作用

View File

@@ -68,15 +68,20 @@ typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
extern "C" {
#endif
extern __declspec(dllexport) void SetOptions(GoUint16 workerId);
extern __declspec(dllexport) GoUint64 NextId();
// 注册一个新的WorkerId
extern __declspec(dllexport) GoInt RegisterWorkerId(char* ip, GoInt port, char* password, GoInt maxWorkerId);
// 注册一个 WorkerId,会先注销所有本机已注册的记录
extern __declspec(dllexport) GoInt32 RegisterOne(char* ip, GoInt32 port, char* password, GoInt32 maxWorkerId);
// 注WorkerId
extern __declspec(dllexport) void UnRegisterWorkerId();
// 注册多个 WorkerId,会先注销所有本机已注册的记录
extern __declspec(dllexport) int* RegisterMany(char* ip, GoInt32 port, char* password, GoInt32 maxWorkerId, GoInt32 totalCount);
// 检查本地WorkerId是否有效
extern __declspec(dllexport) GoUint8 ValidateLocalWorkerId(GoInt workerId);
// 注销本机已注册的 WorkerId
extern __declspec(dllexport) void UnRegister();
// 检查本地WorkerId是否有效0-有效,其它-无效)
extern __declspec(dllexport) GoInt32 Validate(GoInt32 workerId);
#ifdef __cplusplus
}