2016-12-13 13:05:06 +03:00
|
|
|
package sprint_endpoints
|
2016-12-13 17:31:37 +03:00
|
|
|
|
|
|
|
import (
|
2017-03-16 17:41:09 +03:00
|
|
|
context "context"
|
2016-12-13 17:31:37 +03:00
|
|
|
"fmt"
|
2016-12-15 18:30:14 +03:00
|
|
|
|
2016-12-13 17:31:37 +03:00
|
|
|
"github.com/go-kit/kit/endpoint"
|
2017-03-16 17:41:09 +03:00
|
|
|
oldcontext "golang.org/x/net/context"
|
2019-01-19 22:01:03 +03:00
|
|
|
pb "moul.io/protoc-gen-gotemplate/examples/go-kit/services/sprint/gen/pb"
|
2016-12-13 17:31:37 +03:00
|
|
|
)
|
|
|
|
|
2017-03-16 17:41:09 +03:00
|
|
|
var _ = endpoint.Chain
|
2016-12-13 17:31:37 +03:00
|
|
|
var _ = fmt.Errorf
|
2017-03-16 17:41:09 +03:00
|
|
|
var _ = context.Background
|
2016-12-13 17:31:37 +03:00
|
|
|
|
2016-12-25 21:55:34 +03:00
|
|
|
type StreamEndpoint func(server interface{}, req interface{}) (err error)
|
|
|
|
|
2016-12-13 17:31:37 +03:00
|
|
|
type Endpoints struct {
|
|
|
|
AddSprintEndpoint endpoint.Endpoint
|
|
|
|
|
|
|
|
CloseSprintEndpoint endpoint.Endpoint
|
|
|
|
|
|
|
|
GetSprintEndpoint endpoint.Endpoint
|
|
|
|
}
|
|
|
|
|
2017-03-16 17:41:09 +03:00
|
|
|
func (e *Endpoints) AddSprint(ctx oldcontext.Context, in *pb.AddSprintRequest) (*pb.AddSprintResponse, error) {
|
2016-12-13 17:31:37 +03:00
|
|
|
out, err := e.AddSprintEndpoint(ctx, in)
|
|
|
|
if err != nil {
|
|
|
|
return &pb.AddSprintResponse{ErrMsg: err.Error()}, err
|
|
|
|
}
|
2016-12-13 18:03:16 +03:00
|
|
|
return out.(*pb.AddSprintResponse), err
|
2016-12-13 17:31:37 +03:00
|
|
|
}
|
|
|
|
|
2017-03-16 17:41:09 +03:00
|
|
|
func (e *Endpoints) CloseSprint(ctx oldcontext.Context, in *pb.CloseSprintRequest) (*pb.CloseSprintResponse, error) {
|
2016-12-13 17:31:37 +03:00
|
|
|
out, err := e.CloseSprintEndpoint(ctx, in)
|
|
|
|
if err != nil {
|
|
|
|
return &pb.CloseSprintResponse{ErrMsg: err.Error()}, err
|
|
|
|
}
|
2016-12-13 18:03:16 +03:00
|
|
|
return out.(*pb.CloseSprintResponse), err
|
2016-12-13 17:31:37 +03:00
|
|
|
}
|
|
|
|
|
2017-03-16 17:41:09 +03:00
|
|
|
func (e *Endpoints) GetSprint(ctx oldcontext.Context, in *pb.GetSprintRequest) (*pb.GetSprintResponse, error) {
|
2016-12-13 17:31:37 +03:00
|
|
|
out, err := e.GetSprintEndpoint(ctx, in)
|
|
|
|
if err != nil {
|
|
|
|
return &pb.GetSprintResponse{ErrMsg: err.Error()}, err
|
|
|
|
}
|
2016-12-13 18:03:16 +03:00
|
|
|
return out.(*pb.GetSprintResponse), err
|
2016-12-13 17:31:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
func MakeAddSprintEndpoint(svc pb.SprintServiceServer) endpoint.Endpoint {
|
|
|
|
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
|
|
|
req := request.(*pb.AddSprintRequest)
|
|
|
|
rep, err := svc.AddSprint(ctx, req)
|
|
|
|
if err != nil {
|
2016-12-13 18:03:16 +03:00
|
|
|
return &pb.AddSprintResponse{ErrMsg: err.Error()}, err
|
2016-12-13 17:31:37 +03:00
|
|
|
}
|
|
|
|
return rep, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func MakeCloseSprintEndpoint(svc pb.SprintServiceServer) endpoint.Endpoint {
|
|
|
|
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
|
|
|
req := request.(*pb.CloseSprintRequest)
|
|
|
|
rep, err := svc.CloseSprint(ctx, req)
|
|
|
|
if err != nil {
|
2016-12-13 18:03:16 +03:00
|
|
|
return &pb.CloseSprintResponse{ErrMsg: err.Error()}, err
|
2016-12-13 17:31:37 +03:00
|
|
|
}
|
|
|
|
return rep, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func MakeGetSprintEndpoint(svc pb.SprintServiceServer) endpoint.Endpoint {
|
|
|
|
return func(ctx context.Context, request interface{}) (interface{}, error) {
|
|
|
|
req := request.(*pb.GetSprintRequest)
|
|
|
|
rep, err := svc.GetSprint(ctx, req)
|
|
|
|
if err != nil {
|
2016-12-13 18:03:16 +03:00
|
|
|
return &pb.GetSprintResponse{ErrMsg: err.Error()}, err
|
2016-12-13 17:31:37 +03:00
|
|
|
}
|
|
|
|
return rep, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func MakeEndpoints(svc pb.SprintServiceServer) Endpoints {
|
|
|
|
return Endpoints{
|
|
|
|
|
|
|
|
AddSprintEndpoint: MakeAddSprintEndpoint(svc),
|
|
|
|
|
|
|
|
CloseSprintEndpoint: MakeCloseSprintEndpoint(svc),
|
|
|
|
|
|
|
|
GetSprintEndpoint: MakeGetSprintEndpoint(svc),
|
|
|
|
}
|
|
|
|
}
|