代码拉取完成,页面将自动刷新
package rpc
import (
"gitee.com/h79/goutils/api"
"gitee.com/h79/goutils/common/config"
"gitee.com/h79/goutils/common/result"
"gitee.com/h79/goutils/common/timer"
pb "gitee.com/h79/protobuffs"
)
func CreateEvent(evType int32, content []byte) *pb.Event {
return &pb.Event{
EventType: evType,
ContentType: api.JSON,
Content: string(content),
}
}
func CreateResponseWithHead(recvAt int64, req *pb.Request, code int32, desc string) *pb.Response {
return CreateResponse(recvAt, req.GetTimeAt(), req.GetSeqId(), code, desc)
}
func ReturnResponse(rsp *pb.Response) {
end := timer.CurrentMS()
rsp.SpendAt = end - rsp.TimeAt
}
func CreateResponse(recvAt, clientAt int64, seqId string, code int32, desc string) *pb.Response {
rsp := &pb.Response{
Version: config.Version,
Source: config.Source,
SeqId: seqId,
Errno: code,
Error: "",
Code: code,
Desc: desc,
ServerAt: timer.CurrentMS(),
}
rsp.TimeAt = recvAt
rsp.DiffAt = rsp.ServerAt - clientAt
return rsp
}
func WithError(res *pb.Response, err error) *pb.Response {
if err == nil {
return res
}
r := result.WithErr(err)
res.Code = r.Errno
res.SubCode = r.SubCode
res.Desc = r.Desc
res.Msg = r.Msg
res.Errno = r.Errno
res.Error = r.Error()
return res
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。