mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-02 11:59:00 +08:00
Add proxyservice/proxynode/indexservice/indexnode wrapper
Signed-off-by: sunby <bingyi.sun@zilliz.com>
This commit is contained in:
parent
94dfab5b21
commit
675426ea07
34
cmd/distributed/components/index_node.go
Normal file
34
cmd/distributed/components/index_node.go
Normal file
@ -0,0 +1,34 @@
|
||||
package components
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
grpcindexnode "github.com/zilliztech/milvus-distributed/internal/distributed/indexnode"
|
||||
)
|
||||
|
||||
type IndexNode struct {
|
||||
svr *grpcindexnode.Server
|
||||
}
|
||||
|
||||
func NewIndexNode(ctx context.Context) (*IndexNode, error) {
|
||||
n := &IndexNode{}
|
||||
svr, err := grpcindexnode.NewServer(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
n.svr = svr
|
||||
return n, nil
|
||||
|
||||
}
|
||||
func (n *IndexNode) Run() error {
|
||||
if err := n.svr.Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (n *IndexNode) Stop() error {
|
||||
if err := n.svr.Stop(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
33
cmd/distributed/components/index_service.go
Normal file
33
cmd/distributed/components/index_service.go
Normal file
@ -0,0 +1,33 @@
|
||||
package components
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
grpcindexserver "github.com/zilliztech/milvus-distributed/internal/distributed/indexservice"
|
||||
)
|
||||
|
||||
type IndexService struct {
|
||||
svr *grpcindexserver.Server
|
||||
}
|
||||
|
||||
func NewIndexService(ctx context.Context) (*IndexService, error) {
|
||||
s := &IndexService{}
|
||||
svr, err := grpcindexserver.NewServer(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.svr = svr
|
||||
return s, nil
|
||||
}
|
||||
func (s *IndexService) Run() error {
|
||||
if err := s.svr.Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (s *IndexService) Stop() error {
|
||||
if err := s.svr.Stop(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
33
cmd/distributed/components/proxy_node.go
Normal file
33
cmd/distributed/components/proxy_node.go
Normal file
@ -0,0 +1,33 @@
|
||||
package components
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
grpcproxynode "github.com/zilliztech/milvus-distributed/internal/distributed/proxynode"
|
||||
)
|
||||
|
||||
type ProxyNode struct {
|
||||
svr *grpcproxynode.Server
|
||||
}
|
||||
|
||||
func NewProxyNode(ctx context.Context) (*ProxyNode, error) {
|
||||
n := &ProxyNode{}
|
||||
svr, err := grpcproxynode.NewServer(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
n.svr = svr
|
||||
return n, nil
|
||||
}
|
||||
func (n *ProxyNode) Run() error {
|
||||
if err := n.svr.Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (n *ProxyNode) Stop() error {
|
||||
if err := n.svr.Stop(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
33
cmd/distributed/components/proxy_service.go
Normal file
33
cmd/distributed/components/proxy_service.go
Normal file
@ -0,0 +1,33 @@
|
||||
package components
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
grpcproxyservice "github.com/zilliztech/milvus-distributed/internal/distributed/proxyservice"
|
||||
)
|
||||
|
||||
type ProxyService struct {
|
||||
svr *grpcproxyservice.Server
|
||||
}
|
||||
|
||||
func NewProxyService(ctx context.Context) (*ProxyService, error) {
|
||||
service := &ProxyService{}
|
||||
svr, err := grpcproxyservice.NewServer(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
service.svr = svr
|
||||
return service, nil
|
||||
}
|
||||
func (s *ProxyService) Run() error {
|
||||
if err := s.svr.Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (s *ProxyService) Stop() error {
|
||||
if err := s.svr.Stop(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
@ -18,13 +18,14 @@ import (
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
grpcindexnode "github.com/zilliztech/milvus-distributed/internal/distributed/indexnode"
|
||||
"github.com/zilliztech/milvus-distributed/cmd/distributed/components"
|
||||
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
svr, err := grpcindexnode.NewServer(ctx)
|
||||
n, err := components.NewIndexNode(ctx)
|
||||
if err != nil {
|
||||
log.Print("create server failed", zap.Error(err))
|
||||
}
|
||||
@ -42,14 +43,16 @@ func main() {
|
||||
cancel()
|
||||
}()
|
||||
|
||||
if err := svr.Run(); err != nil {
|
||||
if err := n.Run(); err != nil {
|
||||
log.Fatal("run builder server failed", zap.Error(err))
|
||||
}
|
||||
|
||||
<-ctx.Done()
|
||||
log.Print("Got signal to exit", zap.String("signal", sig.String()))
|
||||
|
||||
svr.Stop()
|
||||
if err := n.Stop(); err != nil {
|
||||
log.Fatal("stop builder server failed", zap.Error(err))
|
||||
}
|
||||
switch sig {
|
||||
case syscall.SIGTERM:
|
||||
exit(0)
|
||||
|
@ -18,13 +18,14 @@ import (
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
grpcindexserver "github.com/zilliztech/milvus-distributed/internal/distributed/indexservice"
|
||||
"github.com/zilliztech/milvus-distributed/cmd/distributed/components"
|
||||
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
svr, err := grpcindexserver.NewServer(ctx)
|
||||
s, err := components.NewIndexService(ctx)
|
||||
if err != nil {
|
||||
log.Print("create server failed", zap.Error(err))
|
||||
}
|
||||
@ -42,14 +43,14 @@ func main() {
|
||||
cancel()
|
||||
}()
|
||||
|
||||
if err := svr.Run(); err != nil {
|
||||
if err := s.Run(); err != nil {
|
||||
log.Fatal("run builder server failed", zap.Error(err))
|
||||
}
|
||||
|
||||
<-ctx.Done()
|
||||
log.Print("Got signal to exit", zap.String("signal", sig.String()))
|
||||
|
||||
if err := svr.Stop(); err != nil {
|
||||
if err := s.Stop(); err != nil {
|
||||
log.Fatal("stop server failed", zap.Error(err))
|
||||
}
|
||||
|
||||
|
@ -7,14 +7,14 @@ import (
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
grpcproxynode "github.com/zilliztech/milvus-distributed/internal/distributed/proxynode"
|
||||
"github.com/zilliztech/milvus-distributed/cmd/distributed/components"
|
||||
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
svr, err := grpcproxynode.NewServer(ctx)
|
||||
n, err := components.NewProxyNode(ctx)
|
||||
if err != nil {
|
||||
log.Print("create server failed", zap.Error(err))
|
||||
}
|
||||
@ -33,14 +33,14 @@ func main() {
|
||||
cancel()
|
||||
}()
|
||||
|
||||
if err := svr.Run(); err != nil {
|
||||
if err := n.Run(); err != nil {
|
||||
log.Fatal("Init server failed", zap.Error(err))
|
||||
}
|
||||
|
||||
<-ctx.Done()
|
||||
log.Print("Got signal to exit", zap.String("signal", sig.String()))
|
||||
|
||||
if err := svr.Stop(); err != nil {
|
||||
if err := n.Stop(); err != nil {
|
||||
log.Fatal("stop server failed", zap.Error(err))
|
||||
}
|
||||
switch sig {
|
||||
|
@ -7,18 +7,17 @@ import (
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
grpcproxyservice "github.com/zilliztech/milvus-distributed/internal/distributed/proxyservice"
|
||||
"github.com/zilliztech/milvus-distributed/cmd/distributed/components"
|
||||
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
svr, err := grpcproxyservice.NewServer(ctx)
|
||||
s, err := components.NewProxyService(ctx)
|
||||
if err != nil {
|
||||
log.Print("create server failed", zap.Error(err))
|
||||
log.Fatal("create proxy service error: " + err.Error())
|
||||
}
|
||||
|
||||
sc := make(chan os.Signal, 1)
|
||||
signal.Notify(sc,
|
||||
syscall.SIGHUP,
|
||||
@ -33,14 +32,14 @@ func main() {
|
||||
cancel()
|
||||
}()
|
||||
|
||||
if err := svr.Run(); err != nil {
|
||||
if err := s.Run(); err != nil {
|
||||
log.Fatal("init server failed", zap.Error(err))
|
||||
}
|
||||
|
||||
<-ctx.Done()
|
||||
log.Print("Got signal to exit", zap.String("signal", sig.String()))
|
||||
|
||||
if err := svr.Stop(); err != nil {
|
||||
if err := s.Stop(); err != nil {
|
||||
log.Fatal("stop server failed", zap.Error(err))
|
||||
}
|
||||
switch sig {
|
||||
|
Loading…
Reference in New Issue
Block a user