feat grpc模块
This commit is contained in:
34
module/grpc.go
Normal file
34
module/grpc.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package module
|
||||
|
||||
import (
|
||||
"git.hlsq.asia/mmorpg/service-common/net/grpc/service"
|
||||
)
|
||||
|
||||
// Grpc Grpc模块
|
||||
type Grpc struct {
|
||||
server service.IService
|
||||
}
|
||||
|
||||
func (m *Grpc) Init() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Grpc) Start() error {
|
||||
m.server.Init()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Grpc) Stop() error {
|
||||
m.server.Close()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Grpc) Bind(data ...any) Module {
|
||||
if data == nil || len(data) == 0 {
|
||||
return m
|
||||
}
|
||||
if ser, ok := data[0].(service.IService); ok {
|
||||
m.server = ser
|
||||
}
|
||||
return m
|
||||
}
|
||||
Reference in New Issue
Block a user