2021-01-24 21:20:11 +08:00
|
|
|
package datanode
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/commonpb"
|
|
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/masterpb"
|
|
|
|
)
|
|
|
|
|
|
|
|
type (
|
|
|
|
allocator interface {
|
|
|
|
allocID() (UniqueID, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
allocatorImpl struct {
|
|
|
|
masterService MasterServiceInterface
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
func newAllocatorImpl(s MasterServiceInterface) *allocatorImpl {
|
|
|
|
return &allocatorImpl{
|
|
|
|
masterService: s,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (alloc *allocatorImpl) allocID() (UniqueID, error) {
|
|
|
|
resp, err := alloc.masterService.AllocID(&masterpb.IDRequest{
|
|
|
|
Base: &commonpb.MsgBase{
|
2021-01-29 17:08:31 +08:00
|
|
|
MsgType: commonpb.MsgType_kRequestID,
|
2021-01-25 18:33:10 +08:00
|
|
|
MsgID: 1, // GOOSE TODO
|
2021-01-24 21:20:11 +08:00
|
|
|
Timestamp: 0, // GOOSE TODO
|
|
|
|
SourceID: Params.NodeID,
|
|
|
|
},
|
|
|
|
Count: 1,
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
return resp.ID, nil
|
|
|
|
}
|