Browse Source

rpc服务端返回内容处理

master
xyiege 3 months ago
parent
commit
8e41218ed8
  1. 2
      aufs/core/dtmem.go
  2. 2
      scagent/app.conf
  3. 9
      scagent/core/JsonRpc.go

2
aufs/core/dtmem.go

@ -37,7 +37,7 @@ func Dtmem(w http.ResponseWriter, r *http.Request) {
}
// 调用远程方法
var reply string
var args = Args{"/www"}
var args = Args{"."}
err = client.Call("FileRpcService.GetFilePath", args, &reply)
if err != nil {
fmt.Fprintf(w, "jsonrpc call faild %v", err)

2
scagent/app.conf

@ -1,2 +1,2 @@
[rpc]
port=9099
port=9098

9
scagent/core/JsonRpc.go

@ -1,6 +1,7 @@
package core
import (
"encoding/json"
"os"
"path/filepath"
"scagnet/util"
@ -71,5 +72,13 @@ func (f *FileRpc) GetFilePath(args *Args, replay *Reply) error {
flplist.Flist = append(flplist.Flist, FloopJson{Path: file, Size: d.Size(), Hash: hash})
}
// 将文件列表转换为json字符串
jsonStr, err := json.Marshal(flplist)
if err != nil {
logger.Error("转换为json字符串出错", zap.Error(err))
return err
}
replay.FilePath = string(jsonStr)
return nil
}

Loading…
Cancel
Save