mirror of
https://gitee.com/johng/gf
synced 2026-07-08 14:39:50 +08:00
add package contrib/rpc/grpcx (#2169)
This commit is contained in:
0
example/rpc/grpcx/basic/client/config.yaml
Normal file
0
example/rpc/grpcx/basic/client/config.yaml
Normal file
32
example/rpc/grpcx/basic/client/main.go
Normal file
32
example/rpc/grpcx/basic/client/main.go
Normal file
@ -0,0 +1,32 @@
|
||||
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/contrib/rpc/grpcx/v2"
|
||||
"github.com/gogf/gf/example/rpc/grpcx/basic/protocol"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gctx"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var (
|
||||
ctx = gctx.GetInitCtx()
|
||||
client = protocol.NewEchoClient(grpcx.Client.MustNewGrpcClientConn("demo"))
|
||||
)
|
||||
for i := 0; i < 100; i++ {
|
||||
res, err := client.Say(ctx, &protocol.SayReq{Content: "Hello"})
|
||||
if err != nil {
|
||||
g.Log().Error(ctx, err)
|
||||
return
|
||||
}
|
||||
g.Log().Print(ctx, "Response:", res.Content)
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user