mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-04 12:59:23 +08:00
7b9fdd7f29
Signed-off-by: godchen <qingxiang.chen@zilliz.com>
42 lines
816 B
Go
42 lines
816 B
Go
package datanode
|
|
|
|
import (
|
|
"context"
|
|
|
|
"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) {
|
|
ctx := context.TODO()
|
|
resp, err := alloc.masterService.AllocID(ctx, &masterpb.IDRequest{
|
|
Base: &commonpb.MsgBase{
|
|
MsgType: commonpb.MsgType_kRequestID,
|
|
MsgID: 1, // GOOSE TODO
|
|
Timestamp: 0, // GOOSE TODO
|
|
SourceID: Params.NodeID,
|
|
},
|
|
Count: 1,
|
|
})
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
return resp.ID, nil
|
|
}
|