milvus/internal/proxyservice/nodeid_allocator.go
bigsheeper 68cd15af63 Get index info from master
Signed-off-by: bigsheeper <yihao.dai@zilliz.com>
2021-01-27 14:41:56 +08:00

39 lines
742 B
Go

package proxyservice
import (
"context"
"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 NaiveNodeIDAllocatorImpl struct {
impl *allocator.IDAllocator
}
func (allocator *NaiveNodeIDAllocatorImpl) AllocOne() UniqueID {
id, err := allocator.impl.AllocOne()
if err != nil {
panic(err)
}
return id
}
func NewNodeIDAllocator() NodeIDAllocator {
impl, err := allocator.NewIDAllocator(context.Background(), Params.MasterAddress())
if err != nil {
panic(err)
}
return &NaiveNodeIDAllocatorImpl{
impl: impl,
}
}