go-common/app/service/live/xroom-feed/internal/server/grpc/server.go
2019-04-22 18:49:16 +08:00

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
}