mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-01 19:39:21 +08:00
2835bcdc4e
Signed-off-by: neza2017 <yefu.chen@zilliz.com>
41 lines
853 B
Go
41 lines
853 B
Go
package datanode
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/zilliztech/milvus-distributed/internal/types"
|
|
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/commonpb"
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/masterpb"
|
|
)
|
|
|
|
type allocatorInterface interface {
|
|
allocID() (UniqueID, error)
|
|
}
|
|
type allocator struct {
|
|
masterService types.MasterService
|
|
}
|
|
|
|
func newAllocator(s types.MasterService) *allocator {
|
|
return &allocator{
|
|
masterService: s,
|
|
}
|
|
}
|
|
|
|
func (alloc *allocator) 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
|
|
}
|