1 Star 0 Fork 0

vick/kinfu

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.go 1.27 KB
一键复制 编辑 原始数据 按行查看 历史
package main
import (
"context"
"errors"
"fmt"
"gitee.com/wu-jin-feng/kinfu/fgin"
reflectPb "gitee.com/wu-jin-feng/kinfu/fgin/demos/fplugs_grpc_test/pb"
_ "gitee.com/wu-jin-feng/kinfu/fgin/demos/fplugs_grpc_test/plugs"
)
type DemoServiceServer struct {
reflectPb.UnimplementedDemoServiceServer
}
func (s *DemoServiceServer) GetScheme(ctx context.Context, req *reflectPb.GetSchemeReq) (*reflectPb.GetSchemeResp, error) {
if req.Info == nil {
return nil, errors.New("info 不能为空")
}
resp, err := grpcClient.GetScheme(ctx, &reflectPb.GetSchemeReq{
Path: "123",
Info: &reflectPb.GetSchemeRespInfo{
Info: "xxxxxx",
Name: "gogopythonpython",
},
})
if err != nil {
return nil, err
}
fmt.Println("grpc test_web1 resp:", resp)
endData := &reflectPb.GetSchemeResp{
Data: req.Path + ",gogogo",
Info: &reflectPb.GetSchemeRespInfo{
Info: fmt.Sprintf("这是一个info,%s", req.Info.Info),
Name: fmt.Sprintf("作者是%s", req.Info.Name),
},
}
return endData, nil
}
var (
grpcClient reflectPb.DemoServiceClient
)
func main() {
f := fgin.Fgin{}
s := f.GetGrpcServer("./test.yaml")
reflectPb.RegisterDemoServiceServer(s, &DemoServiceServer{})
conn, _ := f.GetFgrpcClientConn("test_web1")
grpcClient = reflectPb.NewDemoServiceClient(conn)
f.RunGrpc(s)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/wu-jin-feng/kinfu.git
git@gitee.com:wu-jin-feng/kinfu.git
wu-jin-feng
kinfu
kinfu
63ab2dd32d62

搜索帮助

0d507c66 1850385 C8b1a773 1850385