1 Star 0 Fork 0

micro-tools/micro

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
server.go 970 Bytes
一键复制 编辑 原始数据 按行查看 历史
545403892 提交于 2023-06-05 23:58 +08:00 . init
package main
import (
"gitee.com/micro-tools/micro/module"
"gitee.com/micro-tools/micro/module/base"
pf "gitee.com/micro-tools/wf/extend/pb/protobuf"
"gitee.com/micro-tools/wf/extend/utils/gmicro/server"
"google.golang.org/grpc"
)
type Server struct {
base.Module
}
func New() module.Module {
this := new(Server)
return this
}
func (s *Server) GetType() string {
return "server"
}
func (s *Server) OnInit(app module.App) {
s.Module.OnInit(s, app, server.RPCBind(func(sv *grpc.Server) {
pf.RegisterUserServer(sv, &User{})
pf.RegisterOrderServer(sv, &Order{})
app.Logger().Infof("protocol user register")
app.Logger().Infof("protocol order register")
}))
}
func (s *Server) Run(closeSig chan bool) {
s.App.Logger().Infof("%s模块运行中...", s.GetType())
<-closeSig
s.App.Logger().Infof("%s模块已停止...", s.GetType())
}
func (s *Server) OnDestroy() {
s.Module.OnDestroy()
s.App.Logger().Infof("%s模块已回收...", s.GetType())
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/micro-tools/micro.git
git@gitee.com:micro-tools/micro.git
micro-tools
micro
micro
v1.0.2

搜索帮助