milvus/internal/proxyservice/nodeid_allocator.go
dragondriver d972b75aaa Add GetTimeTickChannel, GetComponentStates to proxy service
Signed-off-by: dragondriver <jiquan.long@zilliz.com>
2021-01-26 14:55:57 +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,
}
}