style: put server in its own package

This commit is contained in:
Jefferson Girão
2020-02-04 10:37:32 +01:00
parent 19c7c21718
commit 9806e518fd
3 changed files with 18 additions and 9 deletions
+16
View File
@@ -0,0 +1,16 @@
package app
import (
"context"
pb "github.com/spotify/backstage/inventory/protos"
)
// Server is the inventory GRPC server
type Server struct {
}
// GetEntity returns an inventory Entitity with the selected facts
func (s *Server) GetEntity(ctx context.Context, req *pb.GetEntityRequest) (*pb.GetEntityReply, error) {
return &pb.GetEntityReply{}, nil
}
BIN
View File
Binary file not shown.
+2 -9
View File
@@ -1,10 +1,10 @@
package main
import (
"context"
"log"
"net"
"github.com/spotify/backstage/inventory/app"
pb "github.com/spotify/backstage/inventory/protos"
"google.golang.org/grpc"
)
@@ -13,19 +13,12 @@ const (
port = ":50051"
)
type inventoryServer struct {
}
func (s *inventoryServer) GetEntity(ctx context.Context, req *pb.GetEntityRequest) (*pb.GetEntityReply, error) {
return &pb.GetEntityReply{}, nil
}
func main() {
lis, err := net.Listen("tcp", port)
if err != nil {
log.Fatalf("failed to listen: %v", err)
}
grpcServer := grpc.NewServer()
pb.RegisterInventoryServer(grpcServer, &inventoryServer{})
pb.RegisterInventoryServer(grpcServer, &app.Server{})
grpcServer.Serve(lis)
}