mirror of https://github.com/milvus-io/milvus.git
Fix golint error in proxy (#9834)
Signed-off-by: zhenshan.cao <zhenshan.cao@zilliz.com>pull/9770/head
parent
c2c927bd55
commit
3b230b5cd9
|
@ -32,7 +32,6 @@ type idAllocatorInterface interface {
|
|||
}
|
||||
|
||||
// use timestampAllocatorInterface to keep other components testable
|
||||
// include: TimestampAllocator
|
||||
type timestampAllocatorInterface interface {
|
||||
AllocTimestamp(ctx context.Context, req *rootcoordpb.AllocTimestampRequest) (*rootcoordpb.AllocTimestampResponse, error)
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ type Proxy struct {
|
|||
chTicker channelsTimeTicker
|
||||
|
||||
idAllocator *allocator.IDAllocator
|
||||
tsoAllocator *TimestampAllocator
|
||||
tsoAllocator *timestampAllocator
|
||||
segAssigner *segIDAssigner
|
||||
|
||||
metricsCacheManager *metricsinfo.MetricsCacheManager
|
||||
|
@ -180,7 +180,7 @@ func (node *Proxy) Init() error {
|
|||
|
||||
node.idAllocator = idAllocator
|
||||
|
||||
tsoAllocator, err := NewTimestampAllocator(node.ctx, node.rootCoord, Params.ProxyID)
|
||||
tsoAllocator, err := newTimestampAllocator(node.ctx, node.rootCoord, Params.ProxyID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -20,14 +20,14 @@ import (
|
|||
"github.com/milvus-io/milvus/internal/proto/rootcoordpb"
|
||||
)
|
||||
|
||||
type TimestampAllocator struct {
|
||||
type timestampAllocator struct {
|
||||
ctx context.Context
|
||||
tso timestampAllocatorInterface
|
||||
peerID UniqueID
|
||||
}
|
||||
|
||||
func NewTimestampAllocator(ctx context.Context, tso timestampAllocatorInterface, peerID UniqueID) (*TimestampAllocator, error) {
|
||||
a := &TimestampAllocator{
|
||||
func newTimestampAllocator(ctx context.Context, tso timestampAllocatorInterface, peerID UniqueID) (*timestampAllocator, error) {
|
||||
a := ×tampAllocator{
|
||||
ctx: ctx,
|
||||
peerID: peerID,
|
||||
tso: tso,
|
||||
|
@ -35,7 +35,7 @@ func NewTimestampAllocator(ctx context.Context, tso timestampAllocatorInterface,
|
|||
return a, nil
|
||||
}
|
||||
|
||||
func (ta *TimestampAllocator) Alloc(count uint32) ([]Timestamp, error) {
|
||||
func (ta *timestampAllocator) alloc(count uint32) ([]Timestamp, error) {
|
||||
ctx, cancel := context.WithTimeout(ta.ctx, 5*time.Second)
|
||||
req := &rootcoordpb.AllocTimestampRequest{
|
||||
Base: &commonpb.MsgBase{
|
||||
|
@ -65,8 +65,8 @@ func (ta *TimestampAllocator) Alloc(count uint32) ([]Timestamp, error) {
|
|||
return ret, nil
|
||||
}
|
||||
|
||||
func (ta *TimestampAllocator) AllocOne() (Timestamp, error) {
|
||||
ret, err := ta.Alloc(1)
|
||||
func (ta *timestampAllocator) AllocOne() (Timestamp, error) {
|
||||
ret, err := ta.alloc(1)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
|
|
@ -26,22 +26,22 @@ func TestNewTimestampAllocator(t *testing.T) {
|
|||
tso := newMockTimestampAllocatorInterface()
|
||||
peerID := UniqueID(uniquegenerator.GetUniqueIntGeneratorIns().GetInt())
|
||||
|
||||
tsAllocator, err := NewTimestampAllocator(ctx, tso, peerID)
|
||||
tsAllocator, err := newTimestampAllocator(ctx, tso, peerID)
|
||||
assert.Nil(t, err)
|
||||
assert.NotNil(t, tsAllocator)
|
||||
}
|
||||
|
||||
func TestTimestampAllocator_Alloc(t *testing.T) {
|
||||
func TestTimestampAllocator_alloc(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
tso := newMockTimestampAllocatorInterface()
|
||||
peerID := UniqueID(uniquegenerator.GetUniqueIntGeneratorIns().GetInt())
|
||||
|
||||
tsAllocator, err := NewTimestampAllocator(ctx, tso, peerID)
|
||||
tsAllocator, err := newTimestampAllocator(ctx, tso, peerID)
|
||||
assert.Nil(t, err)
|
||||
assert.NotNil(t, tsAllocator)
|
||||
|
||||
count := rand.Uint32()%100 + 1
|
||||
ret, err := tsAllocator.Alloc(count)
|
||||
ret, err := tsAllocator.alloc(count)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, int(count), len(ret))
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ func TestTimestampAllocator_AllocOne(t *testing.T) {
|
|||
tso := newMockTimestampAllocatorInterface()
|
||||
peerID := UniqueID(uniquegenerator.GetUniqueIntGeneratorIns().GetInt())
|
||||
|
||||
tsAllocator, err := NewTimestampAllocator(ctx, tso, peerID)
|
||||
tsAllocator, err := newTimestampAllocator(ctx, tso, peerID)
|
||||
assert.Nil(t, err)
|
||||
assert.NotNil(t, tsAllocator)
|
||||
|
||||
|
|
Loading…
Reference in New Issue