milvus/internal/proxyservice/nodeid_allocator.go
quicksilver 74154a11a4 Fix deploy error during regression stage
Signed-off-by: quicksilver <zhifeng.zhang@zilliz.com>
2021-03-05 16:52:45 +08:00

38 lines
681 B
Go

package proxyservice
import (
"sync"
"github.com/zilliztech/milvus-distributed/internal/allocator"
"github.com/zilliztech/milvus-distributed/internal/util/typeutil"
)
type UniqueID = typeutil.UniqueID
type Timestamp = typeutil.Timestamp
type NodeIDAllocator interface {
AllocOne() UniqueID
}
type NaiveNodeIDAllocator struct {
allocator *allocator.IDAllocator
now UniqueID
mtx sync.Mutex
}
func (allocator *NaiveNodeIDAllocator) AllocOne() UniqueID {
allocator.mtx.Lock()
defer func() {
// allocator.now++
allocator.mtx.Unlock()
}()
return allocator.now
}
func NewNodeIDAllocator() NodeIDAllocator {
return &NaiveNodeIDAllocator{
now: 1,
}
}