2 Star 1 Fork 1

mosache / YFrame

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
services.go 961 Bytes
一键复制 编辑 原始数据 按行查看 历史
ヤ沒脩袮兲︶ 提交于 2023-08-29 18:31 . temp
package rpc
import (
"context"
"errors"
"gitee.com/mosache/YFrame/micro/rpc/testdata"
"gitee.com/mosache/YFrame/micro/rpc/testdata/gen"
"time"
)
type UserServiceImpl struct {
testdata.UserService
}
func (u *UserServiceImpl) GetUserByID(ctx context.Context, req *testdata.GetUserByIDReq) (*testdata.GetUserByIDResp, error) {
return &testdata.GetUserByIDResp{ID: 11}, nil
}
func (u *UserServiceImpl) GetUserByIDProto(ctx context.Context, req *gen.GetUserByIdReq) (*gen.GetUserByIdResp, error) {
return &gen.GetUserByIdResp{Id: 11}, nil
}
type UserServiceTimeOut struct {
sleep time.Duration
}
func (u *UserServiceTimeOut) GetUserByID(ctx context.Context, req *testdata.GetUserByIDReq) (*testdata.GetUserByIDResp, error) {
if _, ok := ctx.Deadline(); !ok {
panic(errors.New("deadline must be set"))
}
time.Sleep(u.sleep)
return &testdata.GetUserByIDResp{ID: 11}, nil
}
func (u *UserServiceTimeOut) Name() string {
return "user-service"
}
Go
1
https://gitee.com/mosache/YFrame.git
git@gitee.com:mosache/YFrame.git
mosache
YFrame
YFrame
v0.1.75

搜索帮助

53164aa7 5694891 3bd8fe86 5694891