From f18e0628ae8b4c1518cfc7a747e66dfc2fbb90a1 Mon Sep 17 00:00:00 2001 From: godchen Date: Sat, 2 Oct 2021 23:09:56 +0800 Subject: [PATCH] Make NewMeta private (#9057) Signed-off-by: godchen --- internal/datacoord/meta.go | 2 +- internal/datacoord/meta_test.go | 4 ++-- internal/datacoord/mock_test.go | 2 +- internal/datacoord/segment_manager_test.go | 4 ++-- internal/datacoord/server.go | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/datacoord/meta.go b/internal/datacoord/meta.go index 066b75ddaf..9bcb0d9537 100644 --- a/internal/datacoord/meta.go +++ b/internal/datacoord/meta.go @@ -38,7 +38,7 @@ type meta struct { } // NewMeta create meta from provided `kv.TxnKV` -func NewMeta(kv kv.TxnKV) (*meta, error) { +func newMeta(kv kv.TxnKV) (*meta, error) { mt := &meta{ client: kv, collections: make(map[UniqueID]*datapb.CollectionInfo), diff --git a/internal/datacoord/meta_test.go b/internal/datacoord/meta_test.go index d1e2d97b4c..d0651345c3 100644 --- a/internal/datacoord/meta_test.go +++ b/internal/datacoord/meta_test.go @@ -124,14 +124,14 @@ func TestMeta_Basic(t *testing.T) { // inject error for `Save` memoryKV := memkv.NewMemoryKV() fkv := &saveFailKV{TxnKV: memoryKV} - meta, err := NewMeta(fkv) + meta, err := newMeta(fkv) assert.Nil(t, err) err = meta.AddSegment(NewSegmentInfo(&datapb.SegmentInfo{})) assert.NotNil(t, err) fkv2 := &removeFailKV{TxnKV: memoryKV} - meta, err = NewMeta(fkv2) + meta, err = newMeta(fkv2) assert.Nil(t, err) // nil, since no segment yet err = meta.DropSegment(0) diff --git a/internal/datacoord/mock_test.go b/internal/datacoord/mock_test.go index 7bdfad89b9..615004649f 100644 --- a/internal/datacoord/mock_test.go +++ b/internal/datacoord/mock_test.go @@ -34,7 +34,7 @@ import ( func newMemoryMeta(allocator allocator) (*meta, error) { memoryKV := memkv.NewMemoryKV() - return NewMeta(memoryKV) + return newMeta(memoryKV) } var _ allocator = (*MockAllocator)(nil) diff --git a/internal/datacoord/segment_manager_test.go b/internal/datacoord/segment_manager_test.go index c99fb4e058..07a5b410c6 100644 --- a/internal/datacoord/segment_manager_test.go +++ b/internal/datacoord/segment_manager_test.go @@ -397,7 +397,7 @@ func TestTryToSealSegment(t *testing.T) { mockAllocator := newMockAllocator() memoryKV := memkv.NewMemoryKV() fkv := &saveFailKV{TxnKV: memoryKV} - meta, err := NewMeta(memoryKV) + meta, err := newMeta(memoryKV) assert.Nil(t, err) @@ -423,7 +423,7 @@ func TestTryToSealSegment(t *testing.T) { mockAllocator := newMockAllocator() memoryKV := memkv.NewMemoryKV() fkv := &saveFailKV{TxnKV: memoryKV} - meta, err := NewMeta(memoryKV) + meta, err := newMeta(memoryKV) assert.Nil(t, err) diff --git a/internal/datacoord/server.go b/internal/datacoord/server.go index 2892b0aef3..d44cdd39a8 100644 --- a/internal/datacoord/server.go +++ b/internal/datacoord/server.go @@ -287,7 +287,7 @@ func (s *Server) initMeta() error { } s.kvClient = etcdKV - s.meta, err = NewMeta(s.kvClient) + s.meta, err = newMeta(s.kvClient) if err != nil { return err }