Browse Source

ping接口不需要参数

gitlink
Sydonian 1 year ago
parent
commit
ecab2e0bc9
4 changed files with 7 additions and 23 deletions
  1. +2
    -2
      common/pkgs/connectivity/collector.go
  2. +2
    -13
      common/pkgs/grpc/agent/agent.pb.go
  3. +1
    -3
      common/pkgs/grpc/agent/agent.proto
  4. +2
    -5
      common/pkgs/grpc/agent/client.go

+ 2
- 2
common/pkgs/connectivity/collector.go View File

@@ -178,7 +178,7 @@ func (r *Collector) ping(node cdssdk.Node) Connectivity {
defer stgglb.AgentRPCPool.Release(agtCli)

// 第一次ping保证网络连接建立成功
err = agtCli.Ping(*stgglb.Local.NodeID)
err = agtCli.Ping()
if err != nil {
log.Warnf("pre ping: %v", err)
return Connectivity{
@@ -192,7 +192,7 @@ func (r *Collector) ping(node cdssdk.Node) Connectivity {
var avgDelay time.Duration
for i := 0; i < 3; i++ {
start := time.Now()
err = agtCli.Ping(*stgglb.Local.NodeID)
err = agtCli.Ping()
if err != nil {
log.Warnf("ping: %v", err)
return Connectivity{


+ 2
- 13
common/pkgs/grpc/agent/agent.pb.go View File

@@ -390,8 +390,6 @@ type PingReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields

FromNodeID int64 `protobuf:"varint,1,opt,name=FromNodeID,proto3" json:"FromNodeID,omitempty"`
}

func (x *PingReq) Reset() {
@@ -426,13 +424,6 @@ func (*PingReq) Descriptor() ([]byte, []int) {
return file_pkgs_grpc_agent_agent_proto_rawDescGZIP(), []int{6}
}

func (x *PingReq) GetFromNodeID() int64 {
if x != nil {
return x.FromNodeID
}
return 0
}

type PingResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@@ -500,10 +491,8 @@ var file_pkgs_grpc_agent_agent_proto_rawDesc = []byte{
0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06, 0x50, 0x6c, 0x61, 0x6e,
0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x50, 0x6c, 0x61, 0x6e, 0x49, 0x44,
0x12, 0x1a, 0x0a, 0x08, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x49, 0x44, 0x18, 0x02, 0x20, 0x01,
0x28, 0x09, 0x52, 0x08, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x49, 0x44, 0x22, 0x29, 0x0a, 0x07,
0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x12, 0x1e, 0x0a, 0x0a, 0x46, 0x72, 0x6f, 0x6d, 0x4e,
0x6f, 0x64, 0x65, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x46, 0x72, 0x6f,
0x6d, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x44, 0x22, 0x0a, 0x0a, 0x08, 0x50, 0x69, 0x6e, 0x67, 0x52,
0x28, 0x09, 0x52, 0x08, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x49, 0x44, 0x22, 0x09, 0x0a, 0x07,
0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x22, 0x0a, 0x0a, 0x08, 0x50, 0x69, 0x6e, 0x67, 0x52,
0x65, 0x73, 0x70, 0x2a, 0x37, 0x0a, 0x14, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x44, 0x61, 0x74,
0x61, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x45,
0x4f, 0x46, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x10, 0x01, 0x12, 0x0c,


+ 1
- 3
common/pkgs/grpc/agent/agent.proto View File

@@ -40,9 +40,7 @@ message FetchStreamReq {
string StreamID = 2;
}

message PingReq {
int64 FromNodeID = 1;
}
message PingReq {}
message PingResp {}

service Agent {


+ 2
- 5
common/pkgs/grpc/agent/client.go View File

@@ -5,7 +5,6 @@ import (
"fmt"
"io"

cdssdk "gitlink.org.cn/cloudream/common/sdks/storage"
"gitlink.org.cn/cloudream/storage/common/pkgs/ioswitch"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
@@ -210,10 +209,8 @@ func (c *Client) FetchStream(planID ioswitch.PlanID, streamID ioswitch.StreamID)
}, nil
}

func (c *Client) Ping(fromNodeID cdssdk.NodeID) error {
_, err := c.cli.Ping(context.Background(), &PingReq{
FromNodeID: int64(fromNodeID),
})
func (c *Client) Ping() error {
_, err := c.cli.Ping(context.Background(), &PingReq{})
return err
}



Loading…
Cancel
Save