package pluginrpc import ( "time" uuidgen "github.com/satori/go.uuid" pb "linkfog.com/pluginx/proto" ) func NewReq(from, to, function string, data []byte) *pb.Req { req := &pb.Req{} req.Header = &pb.Header{ UUID: uuidgen.NewV4().String(), Timestamp: time.Now().Unix(), From: from, To: to, Func: function, } req.Data = data return req } func NewFileStream(from, to, function, name, purpose string) *pb.FileStream { fs := &pb.FileStream{} fs.Header = &pb.Header{ UUID: uuidgen.NewV4().String(), Timestamp: time.Now().Unix(), From: from, To: to, Func: function, } fs.Name = name fs.Purpose = purpose return fs } func NewRes(req *pb.Req, code int32, desc string, data []byte) *pb.Res { res := &pb.Res{} res.Header = &pb.Header{ UUID: req.Header.UUID, Timestamp: time.Now().Unix(), From: req.Header.To, To: req.Header.From, Func: req.Header.Func, } res.Code = code res.Desc = desc res.Data = data return res }