generated from VLADIMIR/template
add service
This commit is contained in:
parent
0e399d92eb
commit
8643af86ee
|
@ -3,6 +3,7 @@ package main
|
|||
import (
|
||||
"context"
|
||||
"evening_detective/internal/app"
|
||||
"evening_detective/internal/services"
|
||||
proto "evening_detective/proto"
|
||||
"log"
|
||||
"net"
|
||||
|
@ -23,7 +24,12 @@ func main() {
|
|||
// Create a gRPC server object
|
||||
s := grpc.NewServer()
|
||||
// Attach the Greeter service to the server
|
||||
proto.RegisterEveningDetectiveServer(s, app.NewServer())
|
||||
proto.RegisterEveningDetectiveServer(
|
||||
s,
|
||||
app.NewServer(
|
||||
services.NewServices(),
|
||||
),
|
||||
)
|
||||
// Serve gRPC server
|
||||
log.Println("Serving gRPC on 0.0.0.0:8080")
|
||||
go func() {
|
||||
|
|
|
@ -2,52 +2,60 @@ package app
|
|||
|
||||
import (
|
||||
"context"
|
||||
"evening_detective/internal/services"
|
||||
proto "evening_detective/proto"
|
||||
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
proto.UnimplementedEveningDetectiveServer
|
||||
|
||||
services *services.Services
|
||||
}
|
||||
|
||||
func NewServer() *Server {
|
||||
return &Server{}
|
||||
func NewServer(
|
||||
services *services.Services,
|
||||
) *Server {
|
||||
return &Server{
|
||||
services: services,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) Ping(_ context.Context, _ *proto.PingReq) (*proto.PingRsp, error) {
|
||||
return &proto.PingRsp{}, nil
|
||||
}
|
||||
|
||||
func (s *Server) AddTeams(context.Context, *proto.AddTeamsReq) (*proto.AddTeamsRsp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method AddTeams not implemented")
|
||||
func (s *Server) AddTeams(ctx context.Context, req *proto.AddTeamsReq) (*proto.AddTeamsRsp, error) {
|
||||
return s.services.AddTeams(ctx, req)
|
||||
}
|
||||
|
||||
func (s *Server) GetTeams(context.Context, *proto.GetTeamsReq) (*proto.GetTeamsRsp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetTeams not implemented")
|
||||
func (s *Server) GetTeams(ctx context.Context, req *proto.GetTeamsReq) (*proto.GetTeamsRsp, error) {
|
||||
return s.services.GetTeams(ctx, req)
|
||||
}
|
||||
|
||||
func (s *Server) GetTeamsCSV(context.Context, *proto.GetTeamsCSVReq) (*proto.GetTeamsCSVRsp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetTeamsCSV not implemented")
|
||||
func (s *Server) GetTeamsCSV(ctx context.Context, req *proto.GetTeamsCSVReq) (*proto.GetTeamsCSVRsp, error) {
|
||||
return s.services.GetTeamsCSV(ctx, req)
|
||||
}
|
||||
|
||||
func (s *Server) DeleteTeams(context.Context, *proto.DeleteTeamsReq) (*proto.DeleteTeamsRsp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method DeleteTeams not implemented")
|
||||
func (s *Server) GetTeam(ctx context.Context, req *proto.GetTeamReq) (*proto.GetTeamRsp, error) {
|
||||
return s.services.GetTeam(ctx, req)
|
||||
}
|
||||
|
||||
func (s *Server) AddAction(context.Context, *proto.AddActionReq) (*proto.AddActionRsp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method AddAction not implemented")
|
||||
func (s *Server) DeleteTeams(ctx context.Context, req *proto.DeleteTeamsReq) (*proto.DeleteTeamsRsp, error) {
|
||||
return s.services.DeleteTeams(ctx, req)
|
||||
}
|
||||
|
||||
func (s *Server) GameStart(context.Context, *proto.GameStartReq) (*proto.GameStartRsp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GameStart not implemented")
|
||||
func (s *Server) AddAction(ctx context.Context, req *proto.AddActionReq) (*proto.AddActionRsp, error) {
|
||||
return s.services.AddAction(ctx, req)
|
||||
}
|
||||
|
||||
func (s *Server) GameStop(context.Context, *proto.GameStopReq) (*proto.GameStopRsp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GameStop not implemented")
|
||||
func (s *Server) GameStart(ctx context.Context, req *proto.GameStartReq) (*proto.GameStartRsp, error) {
|
||||
return s.services.GameStart(ctx, req)
|
||||
}
|
||||
|
||||
func (s *Server) GiveApplications(context.Context, *proto.GiveApplicationsReq) (*proto.GiveApplicationsRsp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GiveApplications not implemented")
|
||||
func (s *Server) GameStop(ctx context.Context, req *proto.GameStopReq) (*proto.GameStopRsp, error) {
|
||||
return s.services.GameStop(ctx, req)
|
||||
}
|
||||
|
||||
func (s *Server) GiveApplications(ctx context.Context, req *proto.GiveApplicationsReq) (*proto.GiveApplicationsRsp, error) {
|
||||
return s.services.GiveApplications(ctx, req)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
package services
|
||||
|
||||
import (
|
||||
"context"
|
||||
"evening_detective/proto"
|
||||
)
|
||||
|
||||
type Services struct{}
|
||||
|
||||
func NewServices() *Services {
|
||||
return &Services{}
|
||||
}
|
||||
|
||||
func (s *Services) GiveApplications(ctx context.Context, req *proto.GiveApplicationsReq) (*proto.GiveApplicationsRsp, error) {
|
||||
panic("unimplemented")
|
||||
}
|
||||
|
||||
func (s *Services) GameStop(ctx context.Context, req *proto.GameStopReq) (*proto.GameStopRsp, error) {
|
||||
panic("unimplemented")
|
||||
}
|
||||
|
||||
func (s *Services) GameStart(ctx context.Context, req *proto.GameStartReq) (*proto.GameStartRsp, error) {
|
||||
panic("unimplemented")
|
||||
}
|
||||
|
||||
func (s *Services) AddAction(ctx context.Context, req *proto.AddActionReq) (*proto.AddActionRsp, error) {
|
||||
panic("unimplemented")
|
||||
}
|
||||
|
||||
func (s *Services) DeleteTeams(ctx context.Context, req *proto.DeleteTeamsReq) (*proto.DeleteTeamsRsp, error) {
|
||||
panic("unimplemented")
|
||||
}
|
||||
|
||||
func (s *Services) GetTeam(ctx context.Context, req *proto.GetTeamReq) (*proto.GetTeamRsp, error) {
|
||||
panic("unimplemented")
|
||||
}
|
||||
|
||||
func (s *Services) GetTeamsCSV(ctx context.Context, req *proto.GetTeamsCSVReq) (*proto.GetTeamsCSVRsp, error) {
|
||||
panic("unimplemented")
|
||||
}
|
||||
|
||||
func (s *Services) GetTeams(ctx context.Context, req *proto.GetTeamsReq) (*proto.GetTeamsRsp, error) {
|
||||
panic("unimplemented")
|
||||
}
|
||||
|
||||
func (s *Services) AddTeams(ctx context.Context, req *proto.AddTeamsReq) (*proto.AddTeamsRsp, error) {
|
||||
panic("unimplemented")
|
||||
}
|
Loading…
Reference in New Issue