28 lines
598 B
Go
28 lines
598 B
Go
|
package grpc
|
||
|
|
||
|
import (
|
||
|
pb "go-common/app/service/live/xroom-feed/api"
|
||
|
"go-common/app/service/live/xroom-feed/internal/service"
|
||
|
"go-common/library/conf/paladin"
|
||
|
"go-common/library/net/rpc/warden"
|
||
|
)
|
||
|
|
||
|
// New new a grpc server.
|
||
|
func New(svc *service.Service) *warden.Server {
|
||
|
var rc struct {
|
||
|
Server *warden.ServerConfig
|
||
|
}
|
||
|
if err := paladin.Get("grpc.toml").UnmarshalTOML(&rc); err != nil {
|
||
|
if err != paladin.ErrNotExist {
|
||
|
panic(err)
|
||
|
}
|
||
|
}
|
||
|
ws := warden.NewServer(rc.Server)
|
||
|
pb.RegisterRecPoolServer(ws.Server(), svc)
|
||
|
ws, err := ws.Start()
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
return ws
|
||
|
}
|