You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
500 B
24 lines
500 B
5 years ago
|
package grpc
|
||
|
|
||
|
import (
|
||
|
pb "{{.ModPrefix}}{{.Name}}/api"
|
||
|
|
||
|
"github.com/bilibili/kratos/pkg/conf/paladin"
|
||
|
"github.com/bilibili/kratos/pkg/net/rpc/warden"
|
||
|
)
|
||
|
|
||
|
// New new a grpc server.
|
||
|
func New(svc pb.DemoServer) (ws *warden.Server, err error) {
|
||
|
var rc struct {
|
||
|
Server *warden.ServerConfig
|
||
|
}
|
||
|
err = paladin.Get("grpc.toml").UnmarshalTOML(&rc)
|
||
|
if err == paladin.ErrNotExist {
|
||
|
err = nil
|
||
|
}
|
||
|
ws = warden.NewServer(rc.Server)
|
||
|
pb.RegisterDemoServer(ws.Server(), svc)
|
||
|
ws, err = ws.Start()
|
||
|
return
|
||
|
}
|