mirror of
https://gitee.com/johng/gf
synced 2026-07-04 04:52:48 +08:00
add package contrib/rpc/grpcx (#2169)
This commit is contained in:
27
example/rpc/grpcx/basic/service/service_echo.go
Normal file
27
example/rpc/grpcx/basic/service/service_echo.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user