25 lines
443 B
Go
Raw Normal View History

2019-12-08 16:59:58 +08:00
package rpc
import (
2019-12-10 18:05:02 +08:00
"fmt"
2019-12-08 16:59:58 +08:00
"net"
"google.golang.org/grpc"
2020-11-11 10:07:45 +08:00
pb "github.com/naiba/nezha/proto"
rpcService "github.com/naiba/nezha/service/rpc"
2019-12-08 16:59:58 +08:00
)
// ServeRPC ...
2019-12-10 18:05:02 +08:00
func ServeRPC(port uint) {
2019-12-08 16:59:58 +08:00
server := grpc.NewServer()
pb.RegisterNezhaServiceServer(server, &rpcService.NezhaHandler{
2019-12-09 18:14:31 +08:00
Auth: &rpcService.AuthHandler{},
2019-12-08 16:59:58 +08:00
})
2019-12-10 18:05:02 +08:00
listen, err := net.Listen("tcp", fmt.Sprintf(":%d", port))
2019-12-08 16:59:58 +08:00
if err != nil {
panic(err)
}
server.Serve(listen)
}