You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

reg.go 1.1 kB

2 years ago
1234567891011121314151617181920212223242526272829303132
  1. package main
  2. import (
  3. "C"
  4. )
  5. import "github.com/yitter/idgenerator-go/regworkerid"
  6. //export RegisterOne
  7. // 注册一个 WorkerId,会先注销所有本机已注册的记录
  8. func RegisterOne(ip *C.char, port int32, password *C.char, maxWorkerId int32, database int) int32 {
  9. return regworkerid.RegisterOne(C.GoString(ip), port, C.GoString(password), maxWorkerId, database)
  10. }
  11. // RegisterMany
  12. // 注册多个 WorkerId,会先注销所有本机已注册的记录
  13. func RegisterMany(ip *C.char, port int32, password *C.char, maxWorkerId, totalCount int32, database int) []int32 {
  14. // return (*C.int)(unsafe.Pointer(&values))
  15. //return regworkerid.RegisterMany(ip, port, password, maxWorkerId, totalCount, database)
  16. return regworkerid.RegisterMany(C.GoString(ip), port, C.GoString(password), maxWorkerId, totalCount, database)
  17. }
  18. //export UnRegister
  19. // 注销本机已注册的 WorkerId
  20. func UnRegister() {
  21. regworkerid.UnRegister()
  22. }
  23. //export Validate
  24. // 检查本地WorkerId是否有效(0-有效,其它-无效)
  25. func Validate(workerId int32) int32 {
  26. return regworkerid.Validate(workerId)
  27. }