mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-03 20:40:26 +08:00
阶段性提交
This commit is contained in:
@@ -17,12 +17,13 @@ import (
|
||||
)
|
||||
|
||||
type RPCClient struct {
|
||||
apiConfig *configs.APIConfig
|
||||
adminClients []pb.AdminServiceClient
|
||||
nodeClients []pb.NodeServiceClient
|
||||
nodeGrantClients []pb.NodeGrantServiceClient
|
||||
nodeClusterClients []pb.NodeClusterServiceClient
|
||||
serverClients []pb.ServerServiceClient
|
||||
apiConfig *configs.APIConfig
|
||||
adminClients []pb.AdminServiceClient
|
||||
nodeClients []pb.NodeServiceClient
|
||||
nodeGrantClients []pb.NodeGrantServiceClient
|
||||
nodeClusterClients []pb.NodeClusterServiceClient
|
||||
nodeIPAddressClients []pb.NodeIPAddressServiceClient
|
||||
serverClients []pb.ServerServiceClient
|
||||
}
|
||||
|
||||
func NewRPCClient(apiConfig *configs.APIConfig) (*RPCClient, error) {
|
||||
@@ -34,6 +35,7 @@ func NewRPCClient(apiConfig *configs.APIConfig) (*RPCClient, error) {
|
||||
nodeClients := []pb.NodeServiceClient{}
|
||||
nodeGrantClients := []pb.NodeGrantServiceClient{}
|
||||
nodeClusterClients := []pb.NodeClusterServiceClient{}
|
||||
nodeIPAddressClients := []pb.NodeIPAddressServiceClient{}
|
||||
serverClients := []pb.ServerServiceClient{}
|
||||
|
||||
conns := []*grpc.ClientConn{}
|
||||
@@ -54,16 +56,18 @@ func NewRPCClient(apiConfig *configs.APIConfig) (*RPCClient, error) {
|
||||
nodeClients = append(nodeClients, pb.NewNodeServiceClient(conn))
|
||||
nodeGrantClients = append(nodeGrantClients, pb.NewNodeGrantServiceClient(conn))
|
||||
nodeClusterClients = append(nodeClusterClients, pb.NewNodeClusterServiceClient(conn))
|
||||
nodeIPAddressClients = append(nodeIPAddressClients, pb.NewNodeIPAddressServiceClient(conn))
|
||||
serverClients = append(serverClients, pb.NewServerServiceClient(conn))
|
||||
}
|
||||
|
||||
return &RPCClient{
|
||||
apiConfig: apiConfig,
|
||||
adminClients: adminClients,
|
||||
nodeClients: nodeClients,
|
||||
nodeGrantClients: nodeGrantClients,
|
||||
nodeClusterClients: nodeClusterClients,
|
||||
serverClients: serverClients,
|
||||
apiConfig: apiConfig,
|
||||
adminClients: adminClients,
|
||||
nodeClients: nodeClients,
|
||||
nodeGrantClients: nodeGrantClients,
|
||||
nodeClusterClients: nodeClusterClients,
|
||||
nodeIPAddressClients: nodeIPAddressClients,
|
||||
serverClients: serverClients,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -95,6 +99,13 @@ func (this *RPCClient) NodeClusterRPC() pb.NodeClusterServiceClient {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *RPCClient) NodeIPAddressRPC() pb.NodeIPAddressServiceClient {
|
||||
if len(this.nodeIPAddressClients) > 0 {
|
||||
return this.nodeIPAddressClients[rands.Int(0, len(this.nodeIPAddressClients)-1)]
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *RPCClient) ServerRPC() pb.ServerServiceClient {
|
||||
if len(this.serverClients) > 0 {
|
||||
return this.serverClients[rands.Int(0, len(this.serverClients)-1)]
|
||||
|
||||
Reference in New Issue
Block a user