1
0
mirror of synced 2025-12-16 18:18:10 +08:00
Files
SnowFlake-IdGenerator/Go/source/reg.go
2022-07-12 18:27:48 +08:00

33 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package main
import (
"C"
)
import "github.com/yitter/idgenerator-go/regworkerid"
//export RegisterOne
// 注册一个 WorkerId会先注销所有本机已注册的记录
func RegisterOne(ip *C.char, port int32, password *C.char, maxWorkerId int32, database int) int32 {
return regworkerid.RegisterOne(C.GoString(ip), port, C.GoString(password), maxWorkerId, database)
}
// RegisterMany
// 注册多个 WorkerId会先注销所有本机已注册的记录
func RegisterMany(ip *C.char, port int32, password *C.char, maxWorkerId, totalCount int32, database int) []int32 {
// return (*C.int)(unsafe.Pointer(&values))
//return regworkerid.RegisterMany(ip, port, password, maxWorkerId, totalCount, database)
return regworkerid.RegisterMany(C.GoString(ip), port, C.GoString(password), maxWorkerId, totalCount, database)
}
//export UnRegister
// 注销本机已注册的 WorkerId
func UnRegister() {
regworkerid.UnRegister()
}
//export Validate
// 检查本地WorkerId是否有效0-有效,其它-无效)
func Validate(workerId int32) int32 {
return regworkerid.Validate(workerId)
}