add package contrib/rpc/grpcx (#2169)

This commit is contained in:
John Guo
2023-03-08 14:12:51 +08:00
committed by GitHub
parent 55690f3738
commit 1cd1449085
112 changed files with 5130 additions and 212 deletions

View File

@ -0,0 +1,27 @@
// 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 service
import (
"fmt"
"context"
"github.com/gogf/gf/example/rpc/grpcx/basic/protocol"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gcmd"
)
// Echo is the service for echo.
type Echo struct{}
// Say implements the protobuf.EchoServer interface.
func (s *Echo) Say(ctx context.Context, r *protocol.SayReq) (*protocol.SayRes, error) {
g.Log().Print(ctx, "Received:", r.Content)
text := fmt.Sprintf(`%s: > %s`, gcmd.GetOpt("node", "default"), r.Content)
return &protocol.SayRes{Content: text}, nil
}