nezha/cmd/dashboard/rpc/rpc.go

25 lines
443 B
Go
Raw Normal View History

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