阶段性提交

This commit is contained in:
刘祥超
2020-09-06 16:19:34 +08:00
parent d7e3cefa4d
commit 9093019c73
185 changed files with 5306 additions and 1832 deletions

View File

@@ -24,6 +24,7 @@ type RPCClient struct {
nodeClusterClients []pb.NodeClusterServiceClient
nodeIPAddressClients []pb.NodeIPAddressServiceClient
serverClients []pb.ServerServiceClient
apiNodeClients []pb.APINodeServiceClient
}
func NewRPCClient(apiConfig *configs.APIConfig) (*RPCClient, error) {
@@ -37,6 +38,7 @@ func NewRPCClient(apiConfig *configs.APIConfig) (*RPCClient, error) {
nodeClusterClients := []pb.NodeClusterServiceClient{}
nodeIPAddressClients := []pb.NodeIPAddressServiceClient{}
serverClients := []pb.ServerServiceClient{}
apiNodeClients := []pb.APINodeServiceClient{}
conns := []*grpc.ClientConn{}
for _, endpoint := range apiConfig.RPC.Endpoints {
@@ -58,6 +60,7 @@ func NewRPCClient(apiConfig *configs.APIConfig) (*RPCClient, error) {
nodeClusterClients = append(nodeClusterClients, pb.NewNodeClusterServiceClient(conn))
nodeIPAddressClients = append(nodeIPAddressClients, pb.NewNodeIPAddressServiceClient(conn))
serverClients = append(serverClients, pb.NewServerServiceClient(conn))
apiNodeClients = append(apiNodeClients, pb.NewAPINodeServiceClient(conn))
}
return &RPCClient{
@@ -68,6 +71,7 @@ func NewRPCClient(apiConfig *configs.APIConfig) (*RPCClient, error) {
nodeClusterClients: nodeClusterClients,
nodeIPAddressClients: nodeIPAddressClients,
serverClients: serverClients,
apiNodeClients: apiNodeClients,
}, nil
}
@@ -113,6 +117,13 @@ func (this *RPCClient) ServerRPC() pb.ServerServiceClient {
return nil
}
func (this *RPCClient) APINodeRPC() pb.APINodeServiceClient {
if len(this.serverClients) > 0 {
return this.apiNodeClients[rands.Int(0, len(this.apiNodeClients)-1)]
}
return nil
}
func (this *RPCClient) Context(adminId int64) context.Context {
ctx := context.Background()
m := maps.Map{