2021-01-10 15:31:37 +08:00
|
|
|
// grpc server
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net"
|
|
|
|
|
|
|
|
"google.golang.org/grpc"
|
2021-01-16 16:28:32 +08:00
|
|
|
|
|
|
|
pb "github.com/esinio/geco/gen/proto/echo/v1"
|
|
|
|
srv "github.com/esinio/geco/service/echo/v1"
|
2021-01-10 15:31:37 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
s := grpc.NewServer()
|
2021-01-16 16:28:32 +08:00
|
|
|
pb.RegisterEchoServiceServer(s, srv.NewService())
|
2021-01-10 15:31:37 +08:00
|
|
|
lis, err := net.Listen("tcp", ":9090")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
defer lis.Close()
|
|
|
|
|
|
|
|
defer s.GracefulStop()
|
|
|
|
|
|
|
|
if err := s.Serve(lis); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|