mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-16 21:50:24 +08:00
优化代码
This commit is contained in:
@@ -571,7 +571,11 @@ func (this *RPCClient) pickConn() *grpc.ClientConn {
|
|||||||
defer this.locker.Unlock()
|
defer this.locker.Unlock()
|
||||||
|
|
||||||
// 检查连接状态
|
// 检查连接状态
|
||||||
if len(this.conns) > 0 {
|
var countConns = len(this.conns)
|
||||||
|
if countConns > 0 {
|
||||||
|
if countConns == 1 {
|
||||||
|
return this.conns[0]
|
||||||
|
}
|
||||||
for _, state := range []connectivity.State{
|
for _, state := range []connectivity.State{
|
||||||
connectivity.Ready,
|
connectivity.Ready,
|
||||||
connectivity.Idle,
|
connectivity.Idle,
|
||||||
|
|||||||
@@ -130,11 +130,8 @@ func (this *ParentAction) RPC() *rpc.RPCClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AdminContext 获取Context
|
// AdminContext 获取Context
|
||||||
|
// 每个请求的context都必须是一个新的实例
|
||||||
func (this *ParentAction) AdminContext() context.Context {
|
func (this *ParentAction) AdminContext() context.Context {
|
||||||
if this.ctx != nil {
|
|
||||||
return this.ctx
|
|
||||||
}
|
|
||||||
|
|
||||||
if this.rpcClient == nil {
|
if this.rpcClient == nil {
|
||||||
rpcClient, err := rpc.SharedRPC()
|
rpcClient, err := rpc.SharedRPC()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -249,7 +249,7 @@
|
|||||||
<span v-else class="red">连接非常慢(平均{{round(node.status.apiAvgCostSeconds)}}秒),请改善当前节点和API节点之间通讯</span>
|
<span v-else class="red">连接非常慢(平均{{round(node.status.apiAvgCostSeconds)}}秒),请改善当前节点和API节点之间通讯</span>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
<span v-else class="disabled">尚未连接</span>
|
<span v-else class="disabled">尚未上报数据</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr v-if="nodeDatetime.length > 0">
|
<tr v-if="nodeDatetime.length > 0">
|
||||||
|
|||||||
Reference in New Issue
Block a user