2 Star 6 Fork 5

Plato/rpc-go-backend

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
testcaller_stub.go 2.87 KB
一键复制 编辑 原始数据 按行查看 历史
CloudGuan 提交于 2022-03-21 18:08 . update: update test case
// Machine generated code
// Code generated by go-idl-tool. DO NOT EDIT 2022-03-17 11:34:04
// source: TestCaller
package example
import (
"context"
"errors"
"gitee.com/dennis-kk/rpc-go-backend/idlrpc/example/pbdata"
"gitee.com/dennis-kk/rpc-go-backend/idlrpc"
"github.com/golang/protobuf/proto"
)
type TestCallerStub struct {
srvImpl ITestCaller
}
func NewTestCallerStub(srvImpl ITestCaller) *TestCallerStub {
return &TestCallerStub{
srvImpl,
}
}
func TestCallerStubCreator(v interface{}) idlrpc.IStub {
if service, ok := v.(ITestCaller); ok {
return &TestCallerStub{
service,
}
}
return nil
}
func (sb *TestCallerStub) GetUUID() idlrpc.SvcUuid {
return SrvUUID
}
func (sb *TestCallerStub) GetServiceName() string {
return SrvName
}
func (sb *TestCallerStub) GetSignature(methodid uint32) string {
var sign string
switch methodid {
case 1:
sign = "SetInfo"
case 2:
sign = "GetInfo"
}
return sign
}
func (sb *TestCallerStub) GetMutipleNum() uint32 {
return 0
}
func (sb *TestCallerStub) OnAfterFork(ctx context.Context) bool {
return sb.srvImpl.OnAfterFork(ctx)
}
func (sb *TestCallerStub) OnTick() bool {
return sb.srvImpl.OnTick()
}
func (sb *TestCallerStub) OnBeforeDestroy() bool {
return sb.srvImpl.OnBeforeDestroy()
}
func (sb *TestCallerStub) GetStatus() idlrpc.ServiceStatus {
return idlrpc.SERVICE_RESOLVED
}
func (sb *TestCallerStub) SetStatus(status idlrpc.ServiceStatus) {
}
func (sb *TestCallerStub) Call(ctx context.Context, methodId uint32, req []byte) (resp []byte, err error) {
//解析header
switch methodId {
case 1:
resp, err = sb.SetInfo(ctx, req)
case 2:
resp, err = sb.GetInfo(ctx, req)
default:
err = errors.New("Method Not Fount!!!!!")
}
return
}
func (sb *TestCallerStub) IsOneWay(methodid uint32) (isoneway bool) {
switch methodid {
case 1:
isoneway = false
case 2:
isoneway = false
default:
isoneway = false
}
return
}
func (sb *TestCallerStub) SetInfo(ctx context.Context, req []byte) (resp []byte, err error) {
if sb == nil {
err = errors.New(SrvName + "Service is not Regist")
return
}
if req == nil {
err = errors.New("Request Function Is InValid")
return
}
//解包协议
pbreq := &pbdata.TestCaller_SetInfoArgs{}
err = proto.Unmarshal(req, pbreq)
if err != nil {
return
}
_1 := pbreq.Arg1
err = sb.srvImpl.SetInfo(ctx, _1)
//构造返回值
return
}
func (sb *TestCallerStub) GetInfo(ctx context.Context, req []byte) (resp []byte, err error) {
if sb == nil {
err = errors.New(SrvName + "Service is not Regist")
return
}
if req == nil {
err = errors.New("Request Function Is InValid")
return
}
//解包协议
pbreq := &pbdata.TestCaller_GetInfoArgs{}
err = proto.Unmarshal(req, pbreq)
if err != nil {
return
}
ret, err := sb.srvImpl.GetInfo(ctx)
//构造返回值
pbret := &pbdata.TestCaller_GetInfoRet{}
pbret.Ret1 = ret
resp, err = proto.Marshal(pbret)
return
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/dennis-kk/rpc-go-backend.git
git@gitee.com:dennis-kk/rpc-go-backend.git
dennis-kk
rpc-go-backend
rpc-go-backend
v0.4.17

搜索帮助