data_coord.go 1.9 KB
Newer Older
1 2 3 4 5 6
// Licensed to the LF AI & Data foundation under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
C
cai.zhang 已提交
7 8
// with the License. You may obtain a copy of the License at
//
9
//     http://www.apache.org/licenses/LICENSE-2.0
C
cai.zhang 已提交
10
//
11 12 13 14 15
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
C
cai.zhang 已提交
16

S
sunby 已提交
17 18 19 20 21
package components

import (
	"context"

22
	"github.com/milvus-io/milvus/api/milvuspb"
G
groot 已提交
23
	"github.com/milvus-io/milvus/internal/log"
G
godchen 已提交
24
	"github.com/milvus-io/milvus/internal/util/dependency"
D
dragondriver 已提交
25

26
	grpcdatacoordclient "github.com/milvus-io/milvus/internal/distributed/datacoord"
S
sunby 已提交
27 28
)

29
// DataCoord implements grpc server of DataCoord server
30
type DataCoord struct {
31
	ctx context.Context
32
	svr *grpcdatacoordclient.Server
S
sunby 已提交
33 34
}

35
// NewDataCoord creates a new DataCoord
G
godchen 已提交
36
func NewDataCoord(ctx context.Context, factory dependency.Factory) (*DataCoord, error) {
X
Xiaofan 已提交
37
	s := grpcdatacoordclient.NewServer(ctx, factory)
S
sunby 已提交
38

39
	return &DataCoord{
40 41
		ctx: ctx,
		svr: s,
S
sunby 已提交
42 43 44
	}, nil
}

45 46
// Run starts service
func (s *DataCoord) Run() error {
47
	if err := s.svr.Run(); err != nil {
S
sunby 已提交
48 49
		return err
	}
G
groot 已提交
50
	log.Debug("DataCoord successfully started")
S
sunby 已提交
51 52 53
	return nil
}

54 55
// Stop terminates service
func (s *DataCoord) Stop() error {
56 57 58
	if err := s.svr.Stop(); err != nil {
		return err
	}
S
sunby 已提交
59 60
	return nil
}
D
dragondriver 已提交
61

62
// GetComponentStates returns DataCoord's states
63
func (s *DataCoord) GetComponentStates(ctx context.Context, request *milvuspb.GetComponentStatesRequest) (*milvuspb.ComponentStates, error) {
D
dragondriver 已提交
64 65
	return s.svr.GetComponentStates(ctx, request)
}