Ver Fonte

目录调整

Tao Zhang há 5 anos atrás
pai
commit
9407d0caab

+ 1 - 1
.gitignore

@@ -1,4 +1,4 @@
 ##
 .idea
 sma/agent
-main
+server/server

+ 0 - 0
heartbeatService.go → server/heartbeatService.go


+ 1 - 1
main.go → server/main.go

@@ -35,7 +35,7 @@ func main() {
 	//2.服务心跳
 	proto.RegisterHeartBeatServer(s, &Heartbeat{})
 	//3.服务治理
-
+	proto.RegisterServiceServer(s, &Service{})
 	//处理链接
 	_ = s.Serve(lis)
 }

+ 4 - 4
online.go → server/online.go

@@ -25,9 +25,9 @@ var (
 )
 
 //追加服务
-func AddService(serviceName string, ip string, port int, workers int, balance int) {
+func AddService(serviceName string, address string, workers int32, balance int32) {
 	now := time.Now().Unix()
-	address := fmt.Sprint("%s%d", ip, port)
+	//address := fmt.Sprint("%s%d", ip, port)
 	if !balanceTable.Has(serviceName) {
 		balanceTable.Put(serviceName, balance)
 	}
@@ -47,7 +47,7 @@ func AddService(serviceName string, ip string, port int, workers int, balance in
 		serviceList = list.New()
 		servicesLoad.Put(serviceName, serviceList)
 	}
-	for i := 0; i < workers; i++ {
+	for i := 0; i < int(workers); i++ {
 		serviceId := fmt.Sprintf("%s_%d", address, i)
 		serviceList.PushBack(serviceId)
 	}
@@ -87,4 +87,4 @@ func Discover(serviceName string) (string, string) {
 	case BALANCE_SEQ:
 	}
 	return "", ""
-}
+}

+ 0 - 0
serverLoadService.go → server/serverLoadService.go


+ 29 - 0
server/serviceManager.go

@@ -0,0 +1,29 @@
+package main
+
+import (
+	"app.yhyue.com/BP/servicerd/proto"
+	"context"
+)
+
+/**
+服务治理
+*/
+type Service struct {
+}
+
+func (s *Service) Registe(ctx context.Context, in *proto.ServiceMeta) (*proto.StringReq, error) {
+	AddService(in.ServiceName, in.ServiceAddr, in.Workers, in.Balance)
+	return &proto.StringReq{Data: "ok"}, nil
+}
+
+func (s *Service) Destory(ctx context.Context, meta *proto.ServiceMeta) (*proto.StringReq, error) {
+	panic("implement me")
+}
+
+func (s *Service) Apply(ctx context.Context, data *proto.ApplyReqData) (*proto.ApplyRepData, error) {
+	panic("implement me")
+}
+
+func (s *Service) Release(ctx context.Context, data *proto.ApplyRepData) (*proto.StringReq, error) {
+	panic("implement me")
+}

+ 0 - 0
snycmap.go → server/snycmap.go