Fix golint for distributed indexnode (#8504)

Signed-off-by: cai.zhang <cai.zhang@zilliz.com>
pull/8491/head
cai.zhang 2021-09-24 20:41:56 +08:00 committed by GitHub
parent 459174d78a
commit 803a083b60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -23,6 +23,7 @@ import (
"github.com/milvus-io/milvus/internal/util/paramtable"
)
// ParamTable is used to record configuration items.
type ParamTable struct {
paramtable.BaseTable
@ -36,9 +37,11 @@ type ParamTable struct {
ServerMaxRecvSize int
}
// Params is an alias for ParamTable.
var Params ParamTable
var once sync.Once
// Init is used to initialize configuration items.
func (pt *ParamTable) Init() {
once.Do(func() {
pt.BaseTable.Init()
@ -56,10 +59,12 @@ func (pt *ParamTable) Init() {
})
}
// LoadFromArgs is used to initialize configuration items from args.
func (pt *ParamTable) LoadFromArgs() {
}
// LoadFromEnv is used to initialize configuration items from env.
func (pt *ParamTable) LoadFromEnv() {
Params.IP = funcutil.GetLocalIP()
}

View File

@ -35,6 +35,7 @@ import (
"google.golang.org/grpc"
)
// Server is the grpc wrapper of IndexNode.
type Server struct {
indexnode types.IndexNode
@ -48,6 +49,7 @@ type Server struct {
closer io.Closer
}
// Run initializes and starts IndexNode's grpc service.
func (s *Server) Run() error {
if err := s.init(); err != nil {
@ -89,6 +91,7 @@ func (s *Server) startGrpcLoop(grpcPort int) {
}
// init initializes IndexNode's grpc service.
func (s *Server) init() error {
var err error
Params.Init()
@ -136,6 +139,7 @@ func (s *Server) init() error {
return nil
}
// start starts IndexNode's grpc service.
func (s *Server) start() error {
err := s.indexnode.Start()
if err != nil {
@ -144,6 +148,7 @@ func (s *Server) start() error {
return nil
}
// Stop stops IndexNode's grpc service.
func (s *Server) Stop() error {
if s.closer != nil {
if err := s.closer.Close(); err != nil {
@ -162,31 +167,38 @@ func (s *Server) Stop() error {
return nil
}
// SetClient sets the IndexNode's instance.
func (s *Server) SetClient(indexNodeClient types.IndexNode) error {
s.indexnode = indexNodeClient
return nil
}
// GetComponentStates gets the component states of IndexNode.
func (s *Server) GetComponentStates(ctx context.Context, req *internalpb.GetComponentStatesRequest) (*internalpb.ComponentStates, error) {
return s.indexnode.GetComponentStates(ctx)
}
// GetTimeTickChannel gets the time tick channel of IndexNode.
func (s *Server) GetTimeTickChannel(ctx context.Context, req *internalpb.GetTimeTickChannelRequest) (*milvuspb.StringResponse, error) {
return s.indexnode.GetTimeTickChannel(ctx)
}
// GetStatisticsChannel gets the statistics channel of IndexNode.
func (s *Server) GetStatisticsChannel(ctx context.Context, req *internalpb.GetStatisticsChannelRequest) (*milvuspb.StringResponse, error) {
return s.indexnode.GetStatisticsChannel(ctx)
}
// CreateIndex sends the create index request to IndexNode.
func (s *Server) CreateIndex(ctx context.Context, req *indexpb.CreateIndexRequest) (*commonpb.Status, error) {
return s.indexnode.CreateIndex(ctx, req)
}
// GetMetrics gets the metrics info of IndexNode.
func (s *Server) GetMetrics(ctx context.Context, request *milvuspb.GetMetricsRequest) (*milvuspb.GetMetricsResponse, error) {
return s.indexnode.GetMetrics(ctx, request)
}
// NewServer create a new IndexNode grpc server.
func NewServer(ctx context.Context) (*Server, error) {
ctx1, cancel := context.WithCancel(ctx)
node, err := indexnode.NewIndexNode(ctx1)