Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于rpc调用的一个小建议 #66

Open
Liuhaihui159357 opened this issue Dec 5, 2023 · 0 comments
Open

关于rpc调用的一个小建议 #66

Liuhaihui159357 opened this issue Dec 5, 2023 · 0 comments

Comments

@Liuhaihui159357
Copy link

rpc接口的调用端可以写出一个通用方法,这样就不用写重复代码了;入参和返回值可以写成通用的。
例如:gochat/api/rpc.go文件,可以改成只用这一个方法就行了。
type TransmitReq struct {
Cmd string //例如:CheckAuth
Body []byte //例如:proto.CheckAuthResponse{}
}

type TransmitRsq struct {
Code int64//错误码
Msg string//具体错误信息
Body []byte
}

func (rpc *RpcLogic) Transmit(req *TransmitReq,rsq *TransmitRsq) {
LogicRpcClient.Call(context.Background(), req.Cmd, req, rsq)
}

@Liuhaihui159357 Liuhaihui159357 changed the title yi g 一个小建议 Dec 5, 2023
@Liuhaihui159357 Liuhaihui159357 changed the title 一个小建议 关于rpc调用的一个小建议 Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant