style: put server in its own package
This commit is contained in:
@@ -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
|
||||
}
|
||||
Executable
BIN
Binary file not shown.
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user