1 Star 0 Fork 0

yonglinux/rpcx-sun-examples

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
service.go 1.31 KB
一键复制 编辑 原始数据 按行查看 历史
yonglinux 提交于 2022-02-18 15:48 +08:00 . update service.go.
// Package example defines datastructure and services.
package example
import (
"context"
"fmt"
_ "github.com/shirou/gopsutil/v3/mem"
)
type Args struct {
A int
B int
}
type Reply struct {
// C int
C map[string]string
}
type Arith int
// func (t *Arith) Mul(ctx context.Context, args *Args, reply *Reply) error {
// reply.C = args.A * args.B
// fmt.Printf("call: %d * %d = %d\n", args.A, args.B, reply.C)
// return nil
// }
// func (t *Arith) Add(ctx context.Context, args *Args, reply *Reply) error {
// reply.C = args.A + args.B
// fmt.Printf("call: %d + %d = %d\n", args.A, args.B, reply.C)
// return nil
// }
func (t *Arith) Chen(ctx context.Context, args *Args, reply *Reply) error {
// v, _ := mem.VirtualMemory()
// reply.C = args.A + args.B
// fmt.printf(int(v.UsedPercent))
// result := HostAll
// m := map[string]string{
// "host":"192.168.0.1",
// "cpu":"80",
// "mem":"160",
// }
// reply.C := Host
reply.C = GetHostAll()
fmt.Printf("Chen--v1.1.4-cache-: %d + %d\n", args.A, args.B)
fmt.Println(reply.C)
return nil
}
func (t *Arith) Say(ctx context.Context, args *string, reply *string) error {
*reply = "hello " + *args
return nil
}
type Greeter struct{}
func (s *Greeter) Say(ctx context.Context, name *string, reply *string) error {
*reply = fmt.Sprintf("hello %s!", *name)
return nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yonglinux/rpcx-sun-examples.git
git@gitee.com:yonglinux/rpcx-sun-examples.git
yonglinux
rpcx-sun-examples
rpcx-sun-examples
master

搜索帮助