Add entrypoint
This commit is contained in:
		
							
								
								
									
										1
									
								
								examples/go-kit/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								examples/go-kit/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | |||||||
|  | /server | ||||||
| @@ -4,10 +4,13 @@ TARGETS_GO :=	$(foreach source, $(SOURCES), $(source)_go) | |||||||
| TARGETS_TMPL :=	$(foreach source, $(SOURCES), $(source)_tmpl) | TARGETS_TMPL :=	$(foreach source, $(SOURCES), $(source)_tmpl) | ||||||
|  |  | ||||||
| .PHONY: build | .PHONY: build | ||||||
| build: $(TARGETS_GO) $(TARGETS_TMPL) | build: server | ||||||
|  |  | ||||||
|  | server: $(TARGETS_GO) $(TARGETS_TMPL) | ||||||
|  | 	go build -o server . | ||||||
|  |  | ||||||
| $(TARGETS_GO): %_go: | $(TARGETS_GO): %_go: | ||||||
| 	protoc --gogo_out=. "$*" | 	protoc --gogo_out=plugins=grpc:. "$*" | ||||||
|  |  | ||||||
| $(TARGETS_TMPL): %_tmpl: | $(TARGETS_TMPL): %_tmpl: | ||||||
| 	@mkdir -p $(dir $*)gen | 	@mkdir -p $(dir $*)gen | ||||||
|   | |||||||
							
								
								
									
										73
									
								
								examples/go-kit/main.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								examples/go-kit/main.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,73 @@ | |||||||
|  | package main | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"context" | ||||||
|  | 	"fmt" | ||||||
|  | 	"net" | ||||||
|  | 	"net/http" | ||||||
|  | 	"os" | ||||||
|  | 	"os/signal" | ||||||
|  | 	"syscall" | ||||||
|  |  | ||||||
|  | 	"github.com/go-kit/kit/log" | ||||||
|  | 	"github.com/gorilla/handlers" | ||||||
|  | 	"google.golang.org/grpc" | ||||||
|  |  | ||||||
|  | 	session_pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/session" | ||||||
|  | 	session_endpoints "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/session/gen/endpoints" | ||||||
|  | 	session_grpctransport "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/session/gen/transports/grpc" | ||||||
|  | 	session_httptransport "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/session/gen/transports/http" | ||||||
|  | 	sessionsvc "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/session/svc" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | func main() { | ||||||
|  | 	mux := http.NewServeMux() | ||||||
|  | 	ctx := context.Background() | ||||||
|  | 	errc := make(chan error) | ||||||
|  | 	s := grpc.NewServer() | ||||||
|  | 	var logger log.Logger | ||||||
|  | 	{ | ||||||
|  | 		logger = log.NewLogfmtLogger(os.Stdout) | ||||||
|  | 		logger = log.NewContext(logger).With("ts", log.DefaultTimestampUTC) | ||||||
|  | 		logger = log.NewContext(logger).With("caller", log.DefaultCaller) | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// initialize services | ||||||
|  | 	{ | ||||||
|  | 		svc := sessionsvc.New() | ||||||
|  | 		endpoints := session_endpoints.MakeEndpoints(svc) | ||||||
|  | 		srv := session_grpctransport.MakeGRPCServer(ctx, endpoints) | ||||||
|  | 		session_pb.RegisterSessionServiceServer(s, srv) | ||||||
|  | 		session_httptransport.RegisterHandlers(ctx, svc, mux, endpoints) | ||||||
|  | 	} | ||||||
|  | 	{ | ||||||
|  | 		//svc := sprintsvc.New() | ||||||
|  |  | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	// start servers | ||||||
|  | 	go func() { | ||||||
|  | 		c := make(chan os.Signal, 1) | ||||||
|  | 		signal.Notify(c, syscall.SIGINT, syscall.SIGTERM) | ||||||
|  | 		errc <- fmt.Errorf("%s", <-c) | ||||||
|  | 	}() | ||||||
|  |  | ||||||
|  | 	go func() { | ||||||
|  | 		logger := log.NewContext(logger).With("transport", "HTTP") | ||||||
|  | 		logger.Log("addr", ":8000") | ||||||
|  | 		errc <- http.ListenAndServe(":8000", handlers.LoggingHandler(os.Stderr, mux)) | ||||||
|  | 	}() | ||||||
|  |  | ||||||
|  | 	go func() { | ||||||
|  | 		logger := log.NewContext(logger).With("transport", "gRPC") | ||||||
|  | 		ln, err := net.Listen("tcp", ":9000") | ||||||
|  | 		if err != nil { | ||||||
|  | 			errc <- err | ||||||
|  | 			return | ||||||
|  | 		} | ||||||
|  | 		logger.Log("addr", ":9000") | ||||||
|  | 		errc <- s.Serve(ln) | ||||||
|  | 	}() | ||||||
|  |  | ||||||
|  | 	logger.Log("exit", <-errc) | ||||||
|  | } | ||||||
| @@ -20,7 +20,7 @@ func (e *Endpoints) Login(ctx context.Context, in *pb.LoginRequest) (*pb.LoginRe | |||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return &pb.LoginResponse{ErrMsg: err.Error()}, err | 		return &pb.LoginResponse{ErrMsg: err.Error()}, err | ||||||
| 	} | 	} | ||||||
| 	return out.(*pb.LoginReply), err | 	return out.(*pb.LoginResponse), err | ||||||
| } | } | ||||||
|  |  | ||||||
| func (e *Endpoints) Logout(ctx context.Context, in *pb.LogoutRequest) (*pb.LogoutResponse, error) { | func (e *Endpoints) Logout(ctx context.Context, in *pb.LogoutRequest) (*pb.LogoutResponse, error) { | ||||||
| @@ -28,7 +28,7 @@ func (e *Endpoints) Logout(ctx context.Context, in *pb.LogoutRequest) (*pb.Logou | |||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return &pb.LogoutResponse{ErrMsg: err.Error()}, err | 		return &pb.LogoutResponse{ErrMsg: err.Error()}, err | ||||||
| 	} | 	} | ||||||
| 	return out.(*pb.LogoutReply), err | 	return out.(*pb.LogoutResponse), err | ||||||
| } | } | ||||||
|  |  | ||||||
| func MakeLoginEndpoint(svc pb.SessionServiceServer) endpoint.Endpoint { | func MakeLoginEndpoint(svc pb.SessionServiceServer) endpoint.Endpoint { | ||||||
| @@ -36,7 +36,7 @@ func MakeLoginEndpoint(svc pb.SessionServiceServer) endpoint.Endpoint { | |||||||
| 		req := request.(*pb.LoginRequest) | 		req := request.(*pb.LoginRequest) | ||||||
| 		rep, err := svc.Login(ctx, req) | 		rep, err := svc.Login(ctx, req) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return &pb.LoginReply{ErrMsg: err.Error()}, err | 			return &pb.LoginResponse{ErrMsg: err.Error()}, err | ||||||
| 		} | 		} | ||||||
| 		return rep, nil | 		return rep, nil | ||||||
| 	} | 	} | ||||||
| @@ -47,7 +47,7 @@ func MakeLogoutEndpoint(svc pb.SessionServiceServer) endpoint.Endpoint { | |||||||
| 		req := request.(*pb.LogoutRequest) | 		req := request.(*pb.LogoutRequest) | ||||||
| 		rep, err := svc.Logout(ctx, req) | 		rep, err := svc.Logout(ctx, req) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return &pb.LogoutReply{ErrMsg: err.Error()}, err | 			return &pb.LogoutResponse{ErrMsg: err.Error()}, err | ||||||
| 		} | 		} | ||||||
| 		return rep, nil | 		return rep, nil | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -1,11 +1,11 @@ | |||||||
| package session_transportgrpc | package session_grpctransport | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
|  |  | ||||||
| 	grpctransport "github.com/go-kit/kit/transport/grpc" | 	grpctransport "github.com/go-kit/kit/transport/grpc" | ||||||
| 	pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/session" | 	pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/session" | ||||||
| 	endpoint "github.com/moul/protoc-gen-gotemplate/examples/go-kit/session/gen/endpoints" | 	endpoint "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/session/gen/endpoints" | ||||||
| 	context "golang.org/x/net/context" | 	context "golang.org/x/net/context" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| @@ -21,7 +21,7 @@ func MakeGRPCServer(ctx context.Context, endpoints endpoint.Endpoints) pb.Sessio | |||||||
| 			endpoints.LoginEndpoint, | 			endpoints.LoginEndpoint, | ||||||
| 			decodeLoginRequest, | 			decodeLoginRequest, | ||||||
| 			encodeLoginResponse, | 			encodeLoginResponse, | ||||||
| 			options, | 			options..., | ||||||
| 		), | 		), | ||||||
|  |  | ||||||
| 		logout: grpctransport.NewServer( | 		logout: grpctransport.NewServer( | ||||||
| @@ -29,7 +29,7 @@ func MakeGRPCServer(ctx context.Context, endpoints endpoint.Endpoints) pb.Sessio | |||||||
| 			endpoints.LogoutEndpoint, | 			endpoints.LogoutEndpoint, | ||||||
| 			decodeLogoutRequest, | 			decodeLogoutRequest, | ||||||
| 			encodeLogoutResponse, | 			encodeLogoutResponse, | ||||||
| 			options, | 			options..., | ||||||
| 		), | 		), | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| @@ -40,12 +40,12 @@ type grpcServer struct { | |||||||
| 	logout grpctransport.Handler | 	logout grpctransport.Handler | ||||||
| } | } | ||||||
|  |  | ||||||
| func (s *grpcServer) Login(ctx context.Context, req *pb.LoginRequest) (*pb.LoginReply, error) { | func (s *grpcServer) Login(ctx context.Context, req *pb.LoginRequest) (*pb.LoginResponse, error) { | ||||||
| 	_, rep, err := s.login.ServeGRPC(ctx, req) | 	_, rep, err := s.login.ServeGRPC(ctx, req) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
| 	} | 	} | ||||||
| 	return rep.(*pb.LoginReply), nil | 	return rep.(*pb.LoginResponse), nil | ||||||
| } | } | ||||||
|  |  | ||||||
| func decodeLoginRequest(ctx context.Context, grpcReq interface{}) (interface{}, error) { | func decodeLoginRequest(ctx context.Context, grpcReq interface{}) (interface{}, error) { | ||||||
| @@ -53,16 +53,16 @@ func decodeLoginRequest(ctx context.Context, grpcReq interface{}) (interface{}, | |||||||
| } | } | ||||||
|  |  | ||||||
| func encodeLoginResponse(ctx context.Context, response interface{}) (interface{}, error) { | func encodeLoginResponse(ctx context.Context, response interface{}) (interface{}, error) { | ||||||
| 	resp := response.(*pb.LoginReply) | 	resp := response.(*pb.LoginResponse) | ||||||
| 	return resp, nil | 	return resp, nil | ||||||
| } | } | ||||||
|  |  | ||||||
| func (s *grpcServer) Logout(ctx context.Context, req *pb.LogoutRequest) (*pb.LogoutReply, error) { | func (s *grpcServer) Logout(ctx context.Context, req *pb.LogoutRequest) (*pb.LogoutResponse, error) { | ||||||
| 	_, rep, err := s.logout.ServeGRPC(ctx, req) | 	_, rep, err := s.logout.ServeGRPC(ctx, req) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
| 	} | 	} | ||||||
| 	return rep.(*pb.LogoutReply), nil | 	return rep.(*pb.LogoutResponse), nil | ||||||
| } | } | ||||||
|  |  | ||||||
| func decodeLogoutRequest(ctx context.Context, grpcReq interface{}) (interface{}, error) { | func decodeLogoutRequest(ctx context.Context, grpcReq interface{}) (interface{}, error) { | ||||||
| @@ -70,6 +70,6 @@ func decodeLogoutRequest(ctx context.Context, grpcReq interface{}) (interface{}, | |||||||
| } | } | ||||||
|  |  | ||||||
| func encodeLogoutResponse(ctx context.Context, response interface{}) (interface{}, error) { | func encodeLogoutResponse(ctx context.Context, response interface{}) (interface{}, error) { | ||||||
| 	resp := response.(*pb.LogoutReply) | 	resp := response.(*pb.LogoutResponse) | ||||||
| 	return resp, nil | 	return resp, nil | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| package session_transporthttp | package session_httptransport | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"encoding/json" | 	"encoding/json" | ||||||
| @@ -9,7 +9,7 @@ import ( | |||||||
| 	gokit_endpoint "github.com/go-kit/kit/endpoint" | 	gokit_endpoint "github.com/go-kit/kit/endpoint" | ||||||
| 	httptransport "github.com/go-kit/kit/transport/http" | 	httptransport "github.com/go-kit/kit/transport/http" | ||||||
| 	pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/session" | 	pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/session" | ||||||
| 	endpoints "github.com/moul/protoc-gen-gotemplate/examples/go-kit/session/gen/endpoints" | 	endpoints "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/session/gen/endpoints" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| func MakeLoginHandler(ctx context.Context, svc pb.SessionServiceServer, endpoint gokit_endpoint.Endpoint) *httptransport.Server { | func MakeLoginHandler(ctx context.Context, svc pb.SessionServiceServer, endpoint gokit_endpoint.Endpoint) *httptransport.Server { | ||||||
| @@ -18,7 +18,7 @@ func MakeLoginHandler(ctx context.Context, svc pb.SessionServiceServer, endpoint | |||||||
| 		endpoint, | 		endpoint, | ||||||
| 		decodeLoginRequest, | 		decodeLoginRequest, | ||||||
| 		encodeLoginResponse, | 		encodeLoginResponse, | ||||||
| 		append([]httptransport.ServerOption{}, httptransport.ServerBefore(jwt.ToHTTPContext()))..., | 		[]httptransport.ServerOption{}..., | ||||||
| 	) | 	) | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -40,7 +40,7 @@ func MakeLogoutHandler(ctx context.Context, svc pb.SessionServiceServer, endpoin | |||||||
| 		endpoint, | 		endpoint, | ||||||
| 		decodeLogoutRequest, | 		decodeLogoutRequest, | ||||||
| 		encodeLogoutResponse, | 		encodeLogoutResponse, | ||||||
| 		append([]httptransport.ServerOption{}, httptransport.ServerBefore(jwt.ToHTTPContext()))..., | 		[]httptransport.ServerOption{}..., | ||||||
| 	) | 	) | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,98 +0,0 @@ | |||||||
| // Code generated by protoc-gen-gogo. |  | ||||||
| // source: services/session/session.proto |  | ||||||
| // DO NOT EDIT! |  | ||||||
|  |  | ||||||
| /* |  | ||||||
| Package session is a generated protocol buffer package. |  | ||||||
|  |  | ||||||
| It is generated from these files: |  | ||||||
| 	services/session/session.proto |  | ||||||
|  |  | ||||||
| It has these top-level messages: |  | ||||||
| 	LoginRequest |  | ||||||
| 	LoginResponse |  | ||||||
| 	LogoutRequest |  | ||||||
| 	LogoutResponse |  | ||||||
| */ |  | ||||||
| package session |  | ||||||
|  |  | ||||||
| import proto "github.com/gogo/protobuf/proto" |  | ||||||
| import fmt "fmt" |  | ||||||
| import math "math" |  | ||||||
|  |  | ||||||
| // Reference imports to suppress errors if they are not otherwise used. |  | ||||||
| var _ = proto.Marshal |  | ||||||
| var _ = fmt.Errorf |  | ||||||
| var _ = math.Inf |  | ||||||
|  |  | ||||||
| // This is a compile-time assertion to ensure that this generated file |  | ||||||
| // is compatible with the proto package it is being compiled against. |  | ||||||
| // A compilation error at this line likely means your copy of the |  | ||||||
| // proto package needs to be updated. |  | ||||||
| const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package |  | ||||||
|  |  | ||||||
| type LoginRequest struct { |  | ||||||
| 	Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` |  | ||||||
| 	Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func (m *LoginRequest) Reset()                    { *m = LoginRequest{} } |  | ||||||
| func (m *LoginRequest) String() string            { return proto.CompactTextString(m) } |  | ||||||
| func (*LoginRequest) ProtoMessage()               {} |  | ||||||
| func (*LoginRequest) Descriptor() ([]byte, []int) { return fileDescriptorSession, []int{0} } |  | ||||||
|  |  | ||||||
| type LoginResponse struct { |  | ||||||
| 	Token  string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` |  | ||||||
| 	ErrMsg string `protobuf:"bytes,2,opt,name=err_msg,json=errMsg,proto3" json:"err_msg,omitempty"` |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func (m *LoginResponse) Reset()                    { *m = LoginResponse{} } |  | ||||||
| func (m *LoginResponse) String() string            { return proto.CompactTextString(m) } |  | ||||||
| func (*LoginResponse) ProtoMessage()               {} |  | ||||||
| func (*LoginResponse) Descriptor() ([]byte, []int) { return fileDescriptorSession, []int{1} } |  | ||||||
|  |  | ||||||
| type LogoutRequest struct { |  | ||||||
| 	Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func (m *LogoutRequest) Reset()                    { *m = LogoutRequest{} } |  | ||||||
| func (m *LogoutRequest) String() string            { return proto.CompactTextString(m) } |  | ||||||
| func (*LogoutRequest) ProtoMessage()               {} |  | ||||||
| func (*LogoutRequest) Descriptor() ([]byte, []int) { return fileDescriptorSession, []int{2} } |  | ||||||
|  |  | ||||||
| type LogoutResponse struct { |  | ||||||
| 	ErrMsg string `protobuf:"bytes,1,opt,name=err_msg,json=errMsg,proto3" json:"err_msg,omitempty"` |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func (m *LogoutResponse) Reset()                    { *m = LogoutResponse{} } |  | ||||||
| func (m *LogoutResponse) String() string            { return proto.CompactTextString(m) } |  | ||||||
| func (*LogoutResponse) ProtoMessage()               {} |  | ||||||
| func (*LogoutResponse) Descriptor() ([]byte, []int) { return fileDescriptorSession, []int{3} } |  | ||||||
|  |  | ||||||
| func init() { |  | ||||||
| 	proto.RegisterType((*LoginRequest)(nil), "session.LoginRequest") |  | ||||||
| 	proto.RegisterType((*LoginResponse)(nil), "session.LoginResponse") |  | ||||||
| 	proto.RegisterType((*LogoutRequest)(nil), "session.LogoutRequest") |  | ||||||
| 	proto.RegisterType((*LogoutResponse)(nil), "session.LogoutResponse") |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func init() { proto.RegisterFile("services/session/session.proto", fileDescriptorSession) } |  | ||||||
|  |  | ||||||
| var fileDescriptorSession = []byte{ |  | ||||||
| 	// 231 bytes of a gzipped FileDescriptorProto |  | ||||||
| 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x6c, 0x50, 0xcb, 0x4a, 0xc5, 0x30, |  | ||||||
| 	0x10, 0x35, 0xc2, 0xed, 0xd5, 0x41, 0xef, 0x62, 0x50, 0x6f, 0xe9, 0x42, 0x24, 0x20, 0xe8, 0xa6, |  | ||||||
| 	0x82, 0x6e, 0x04, 0xc1, 0xa5, 0x2b, 0xdd, 0xb4, 0x1f, 0x20, 0x55, 0x87, 0x52, 0xa4, 0x99, 0x3a, |  | ||||||
| 	0x93, 0xea, 0x27, 0xf8, 0xdb, 0x62, 0x93, 0x68, 0x7d, 0xac, 0xc2, 0xc9, 0xcc, 0x79, 0xcc, 0x81, |  | ||||||
| 	0x43, 0x25, 0x79, 0xed, 0x1e, 0x49, 0xcf, 0x94, 0x54, 0x3b, 0x76, 0xe9, 0x2d, 0x07, 0x61, 0xcf, |  | ||||||
| 	0xb8, 0x8c, 0xd0, 0xde, 0xc0, 0xce, 0x2d, 0xb7, 0x9d, 0xab, 0xe8, 0x65, 0x24, 0xf5, 0x58, 0xc0, |  | ||||||
| 	0xd6, 0xa8, 0x24, 0xae, 0xe9, 0x29, 0x37, 0x47, 0xe6, 0x64, 0xbb, 0xfa, 0xc2, 0x9f, 0xb3, 0xa1, |  | ||||||
| 	0x51, 0x7d, 0x63, 0x79, 0xca, 0x37, 0xc3, 0x2c, 0x61, 0x7b, 0x0d, 0xbb, 0x51, 0x47, 0x07, 0x76, |  | ||||||
| 	0x4a, 0xb8, 0x07, 0x0b, 0xcf, 0xcf, 0xe4, 0xa2, 0x4a, 0x00, 0xb8, 0x86, 0x25, 0x89, 0xdc, 0xf7, |  | ||||||
| 	0xda, 0x46, 0x85, 0x8c, 0x44, 0xee, 0xb4, 0xb5, 0xc7, 0x13, 0x9f, 0x47, 0x9f, 0x82, 0xfc, 0xcb, |  | ||||||
| 	0xb7, 0xa7, 0xb0, 0x4a, 0x6b, 0xd1, 0x67, 0xa6, 0x68, 0xe6, 0x8a, 0xe7, 0xef, 0x06, 0x56, 0x75, |  | ||||||
| 	0xb8, 0xb2, 0x0e, 0x65, 0xe0, 0x25, 0x2c, 0xa6, 0x90, 0xb8, 0x5f, 0xa6, 0x3a, 0xe6, 0xc7, 0x17, |  | ||||||
| 	0x07, 0xbf, 0xbf, 0x83, 0x87, 0xdd, 0xc0, 0x2b, 0xc8, 0x82, 0x2f, 0xfe, 0xd8, 0xf9, 0xce, 0x5b, |  | ||||||
| 	0xac, 0xff, 0xfc, 0x27, 0xf2, 0x43, 0x36, 0x75, 0x7e, 0xf1, 0x11, 0x00, 0x00, 0xff, 0xff, 0xc7, |  | ||||||
| 	0x91, 0x50, 0x79, 0x95, 0x01, 0x00, 0x00, |  | ||||||
| } |  | ||||||
| @@ -20,6 +20,11 @@ import proto "github.com/gogo/protobuf/proto" | |||||||
| import fmt "fmt" | import fmt "fmt" | ||||||
| import math "math" | import math "math" | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	context "golang.org/x/net/context" | ||||||
|  | 	grpc "google.golang.org/grpc" | ||||||
|  | ) | ||||||
|  |  | ||||||
| // Reference imports to suppress errors if they are not otherwise used. | // Reference imports to suppress errors if they are not otherwise used. | ||||||
| var _ = proto.Marshal | var _ = proto.Marshal | ||||||
| var _ = fmt.Errorf | var _ = fmt.Errorf | ||||||
| @@ -41,6 +46,20 @@ func (m *LoginRequest) String() string            { return proto.CompactTextStri | |||||||
| func (*LoginRequest) ProtoMessage()               {} | func (*LoginRequest) ProtoMessage()               {} | ||||||
| func (*LoginRequest) Descriptor() ([]byte, []int) { return fileDescriptorSession, []int{0} } | func (*LoginRequest) Descriptor() ([]byte, []int) { return fileDescriptorSession, []int{0} } | ||||||
|  |  | ||||||
|  | func (m *LoginRequest) GetUsername() string { | ||||||
|  | 	if m != nil { | ||||||
|  | 		return m.Username | ||||||
|  | 	} | ||||||
|  | 	return "" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (m *LoginRequest) GetPassword() string { | ||||||
|  | 	if m != nil { | ||||||
|  | 		return m.Password | ||||||
|  | 	} | ||||||
|  | 	return "" | ||||||
|  | } | ||||||
|  |  | ||||||
| type LoginResponse struct { | type LoginResponse struct { | ||||||
| 	Token  string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` | 	Token  string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` | ||||||
| 	ErrMsg string `protobuf:"bytes,2,opt,name=err_msg,json=errMsg,proto3" json:"err_msg,omitempty"` | 	ErrMsg string `protobuf:"bytes,2,opt,name=err_msg,json=errMsg,proto3" json:"err_msg,omitempty"` | ||||||
| @@ -51,6 +70,20 @@ func (m *LoginResponse) String() string            { return proto.CompactTextStr | |||||||
| func (*LoginResponse) ProtoMessage()               {} | func (*LoginResponse) ProtoMessage()               {} | ||||||
| func (*LoginResponse) Descriptor() ([]byte, []int) { return fileDescriptorSession, []int{1} } | func (*LoginResponse) Descriptor() ([]byte, []int) { return fileDescriptorSession, []int{1} } | ||||||
|  |  | ||||||
|  | func (m *LoginResponse) GetToken() string { | ||||||
|  | 	if m != nil { | ||||||
|  | 		return m.Token | ||||||
|  | 	} | ||||||
|  | 	return "" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (m *LoginResponse) GetErrMsg() string { | ||||||
|  | 	if m != nil { | ||||||
|  | 		return m.ErrMsg | ||||||
|  | 	} | ||||||
|  | 	return "" | ||||||
|  | } | ||||||
|  |  | ||||||
| type LogoutRequest struct { | type LogoutRequest struct { | ||||||
| 	Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` | 	Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` | ||||||
| } | } | ||||||
| @@ -60,6 +93,13 @@ func (m *LogoutRequest) String() string            { return proto.CompactTextStr | |||||||
| func (*LogoutRequest) ProtoMessage()               {} | func (*LogoutRequest) ProtoMessage()               {} | ||||||
| func (*LogoutRequest) Descriptor() ([]byte, []int) { return fileDescriptorSession, []int{2} } | func (*LogoutRequest) Descriptor() ([]byte, []int) { return fileDescriptorSession, []int{2} } | ||||||
|  |  | ||||||
|  | func (m *LogoutRequest) GetToken() string { | ||||||
|  | 	if m != nil { | ||||||
|  | 		return m.Token | ||||||
|  | 	} | ||||||
|  | 	return "" | ||||||
|  | } | ||||||
|  |  | ||||||
| type LogoutResponse struct { | type LogoutResponse struct { | ||||||
| 	ErrMsg string `protobuf:"bytes,1,opt,name=err_msg,json=errMsg,proto3" json:"err_msg,omitempty"` | 	ErrMsg string `protobuf:"bytes,1,opt,name=err_msg,json=errMsg,proto3" json:"err_msg,omitempty"` | ||||||
| } | } | ||||||
| @@ -69,6 +109,13 @@ func (m *LogoutResponse) String() string            { return proto.CompactTextSt | |||||||
| func (*LogoutResponse) ProtoMessage()               {} | func (*LogoutResponse) ProtoMessage()               {} | ||||||
| func (*LogoutResponse) Descriptor() ([]byte, []int) { return fileDescriptorSession, []int{3} } | func (*LogoutResponse) Descriptor() ([]byte, []int) { return fileDescriptorSession, []int{3} } | ||||||
|  |  | ||||||
|  | func (m *LogoutResponse) GetErrMsg() string { | ||||||
|  | 	if m != nil { | ||||||
|  | 		return m.ErrMsg | ||||||
|  | 	} | ||||||
|  | 	return "" | ||||||
|  | } | ||||||
|  |  | ||||||
| func init() { | func init() { | ||||||
| 	proto.RegisterType((*LoginRequest)(nil), "session.LoginRequest") | 	proto.RegisterType((*LoginRequest)(nil), "session.LoginRequest") | ||||||
| 	proto.RegisterType((*LoginResponse)(nil), "session.LoginResponse") | 	proto.RegisterType((*LoginResponse)(nil), "session.LoginResponse") | ||||||
| @@ -76,6 +123,111 @@ func init() { | |||||||
| 	proto.RegisterType((*LogoutResponse)(nil), "session.LogoutResponse") | 	proto.RegisterType((*LogoutResponse)(nil), "session.LogoutResponse") | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // Reference imports to suppress errors if they are not otherwise used. | ||||||
|  | var _ context.Context | ||||||
|  | var _ grpc.ClientConn | ||||||
|  |  | ||||||
|  | // This is a compile-time assertion to ensure that this generated file | ||||||
|  | // is compatible with the grpc package it is being compiled against. | ||||||
|  | const _ = grpc.SupportPackageIsVersion4 | ||||||
|  |  | ||||||
|  | // Client API for SessionService service | ||||||
|  |  | ||||||
|  | type SessionServiceClient interface { | ||||||
|  | 	Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) | ||||||
|  | 	Logout(ctx context.Context, in *LogoutRequest, opts ...grpc.CallOption) (*LogoutResponse, error) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | type sessionServiceClient struct { | ||||||
|  | 	cc *grpc.ClientConn | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func NewSessionServiceClient(cc *grpc.ClientConn) SessionServiceClient { | ||||||
|  | 	return &sessionServiceClient{cc} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (c *sessionServiceClient) Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) { | ||||||
|  | 	out := new(LoginResponse) | ||||||
|  | 	err := grpc.Invoke(ctx, "/session.SessionService/Login", in, out, c.cc, opts...) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, err | ||||||
|  | 	} | ||||||
|  | 	return out, nil | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (c *sessionServiceClient) Logout(ctx context.Context, in *LogoutRequest, opts ...grpc.CallOption) (*LogoutResponse, error) { | ||||||
|  | 	out := new(LogoutResponse) | ||||||
|  | 	err := grpc.Invoke(ctx, "/session.SessionService/Logout", in, out, c.cc, opts...) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, err | ||||||
|  | 	} | ||||||
|  | 	return out, nil | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Server API for SessionService service | ||||||
|  |  | ||||||
|  | type SessionServiceServer interface { | ||||||
|  | 	Login(context.Context, *LoginRequest) (*LoginResponse, error) | ||||||
|  | 	Logout(context.Context, *LogoutRequest) (*LogoutResponse, error) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func RegisterSessionServiceServer(s *grpc.Server, srv SessionServiceServer) { | ||||||
|  | 	s.RegisterService(&_SessionService_serviceDesc, srv) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func _SessionService_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { | ||||||
|  | 	in := new(LoginRequest) | ||||||
|  | 	if err := dec(in); err != nil { | ||||||
|  | 		return nil, err | ||||||
|  | 	} | ||||||
|  | 	if interceptor == nil { | ||||||
|  | 		return srv.(SessionServiceServer).Login(ctx, in) | ||||||
|  | 	} | ||||||
|  | 	info := &grpc.UnaryServerInfo{ | ||||||
|  | 		Server:     srv, | ||||||
|  | 		FullMethod: "/session.SessionService/Login", | ||||||
|  | 	} | ||||||
|  | 	handler := func(ctx context.Context, req interface{}) (interface{}, error) { | ||||||
|  | 		return srv.(SessionServiceServer).Login(ctx, req.(*LoginRequest)) | ||||||
|  | 	} | ||||||
|  | 	return interceptor(ctx, in, info, handler) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func _SessionService_Logout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { | ||||||
|  | 	in := new(LogoutRequest) | ||||||
|  | 	if err := dec(in); err != nil { | ||||||
|  | 		return nil, err | ||||||
|  | 	} | ||||||
|  | 	if interceptor == nil { | ||||||
|  | 		return srv.(SessionServiceServer).Logout(ctx, in) | ||||||
|  | 	} | ||||||
|  | 	info := &grpc.UnaryServerInfo{ | ||||||
|  | 		Server:     srv, | ||||||
|  | 		FullMethod: "/session.SessionService/Logout", | ||||||
|  | 	} | ||||||
|  | 	handler := func(ctx context.Context, req interface{}) (interface{}, error) { | ||||||
|  | 		return srv.(SessionServiceServer).Logout(ctx, req.(*LogoutRequest)) | ||||||
|  | 	} | ||||||
|  | 	return interceptor(ctx, in, info, handler) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | var _SessionService_serviceDesc = grpc.ServiceDesc{ | ||||||
|  | 	ServiceName: "session.SessionService", | ||||||
|  | 	HandlerType: (*SessionServiceServer)(nil), | ||||||
|  | 	Methods: []grpc.MethodDesc{ | ||||||
|  | 		{ | ||||||
|  | 			MethodName: "Login", | ||||||
|  | 			Handler:    _SessionService_Login_Handler, | ||||||
|  | 		}, | ||||||
|  | 		{ | ||||||
|  | 			MethodName: "Logout", | ||||||
|  | 			Handler:    _SessionService_Logout_Handler, | ||||||
|  | 		}, | ||||||
|  | 	}, | ||||||
|  | 	Streams:  []grpc.StreamDesc{}, | ||||||
|  | 	Metadata: "services/session/session.proto", | ||||||
|  | } | ||||||
|  |  | ||||||
| func init() { proto.RegisterFile("services/session/session.proto", fileDescriptorSession) } | func init() { proto.RegisterFile("services/session/session.proto", fileDescriptorSession) } | ||||||
|  |  | ||||||
| var fileDescriptorSession = []byte{ | var fileDescriptorSession = []byte{ | ||||||
|   | |||||||
							
								
								
									
										23
									
								
								examples/go-kit/services/session/svc/service.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								examples/go-kit/services/session/svc/service.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | |||||||
|  | package sessionsvc | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"fmt" | ||||||
|  |  | ||||||
|  | 	"golang.org/x/net/context" | ||||||
|  |  | ||||||
|  | 	pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/session" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type Service struct{} | ||||||
|  |  | ||||||
|  | func New() pb.SessionServiceServer { | ||||||
|  | 	return &Service{} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (svc *Service) Login(ctx context.Context, in *pb.LoginRequest) (*pb.LoginResponse, error) { | ||||||
|  | 	return nil, fmt.Errorf("not implemented") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (svc *Service) Logout(ctx context.Context, in *pb.LogoutRequest) (*pb.LogoutResponse, error) { | ||||||
|  | 	return nil, fmt.Errorf("not implemented") | ||||||
|  | } | ||||||
| @@ -22,7 +22,7 @@ func (e *Endpoints) AddSprint(ctx context.Context, in *pb.AddSprintRequest) (*pb | |||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return &pb.AddSprintResponse{ErrMsg: err.Error()}, err | 		return &pb.AddSprintResponse{ErrMsg: err.Error()}, err | ||||||
| 	} | 	} | ||||||
| 	return out.(*pb.AddSprintReply), err | 	return out.(*pb.AddSprintResponse), err | ||||||
| } | } | ||||||
|  |  | ||||||
| func (e *Endpoints) CloseSprint(ctx context.Context, in *pb.CloseSprintRequest) (*pb.CloseSprintResponse, error) { | func (e *Endpoints) CloseSprint(ctx context.Context, in *pb.CloseSprintRequest) (*pb.CloseSprintResponse, error) { | ||||||
| @@ -30,7 +30,7 @@ func (e *Endpoints) CloseSprint(ctx context.Context, in *pb.CloseSprintRequest) | |||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return &pb.CloseSprintResponse{ErrMsg: err.Error()}, err | 		return &pb.CloseSprintResponse{ErrMsg: err.Error()}, err | ||||||
| 	} | 	} | ||||||
| 	return out.(*pb.CloseSprintReply), err | 	return out.(*pb.CloseSprintResponse), err | ||||||
| } | } | ||||||
|  |  | ||||||
| func (e *Endpoints) GetSprint(ctx context.Context, in *pb.GetSprintRequest) (*pb.GetSprintResponse, error) { | func (e *Endpoints) GetSprint(ctx context.Context, in *pb.GetSprintRequest) (*pb.GetSprintResponse, error) { | ||||||
| @@ -38,7 +38,7 @@ func (e *Endpoints) GetSprint(ctx context.Context, in *pb.GetSprintRequest) (*pb | |||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return &pb.GetSprintResponse{ErrMsg: err.Error()}, err | 		return &pb.GetSprintResponse{ErrMsg: err.Error()}, err | ||||||
| 	} | 	} | ||||||
| 	return out.(*pb.GetSprintReply), err | 	return out.(*pb.GetSprintResponse), err | ||||||
| } | } | ||||||
|  |  | ||||||
| func MakeAddSprintEndpoint(svc pb.SprintServiceServer) endpoint.Endpoint { | func MakeAddSprintEndpoint(svc pb.SprintServiceServer) endpoint.Endpoint { | ||||||
| @@ -46,7 +46,7 @@ func MakeAddSprintEndpoint(svc pb.SprintServiceServer) endpoint.Endpoint { | |||||||
| 		req := request.(*pb.AddSprintRequest) | 		req := request.(*pb.AddSprintRequest) | ||||||
| 		rep, err := svc.AddSprint(ctx, req) | 		rep, err := svc.AddSprint(ctx, req) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return &pb.AddSprintReply{ErrMsg: err.Error()}, err | 			return &pb.AddSprintResponse{ErrMsg: err.Error()}, err | ||||||
| 		} | 		} | ||||||
| 		return rep, nil | 		return rep, nil | ||||||
| 	} | 	} | ||||||
| @@ -57,7 +57,7 @@ func MakeCloseSprintEndpoint(svc pb.SprintServiceServer) endpoint.Endpoint { | |||||||
| 		req := request.(*pb.CloseSprintRequest) | 		req := request.(*pb.CloseSprintRequest) | ||||||
| 		rep, err := svc.CloseSprint(ctx, req) | 		rep, err := svc.CloseSprint(ctx, req) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return &pb.CloseSprintReply{ErrMsg: err.Error()}, err | 			return &pb.CloseSprintResponse{ErrMsg: err.Error()}, err | ||||||
| 		} | 		} | ||||||
| 		return rep, nil | 		return rep, nil | ||||||
| 	} | 	} | ||||||
| @@ -68,7 +68,7 @@ func MakeGetSprintEndpoint(svc pb.SprintServiceServer) endpoint.Endpoint { | |||||||
| 		req := request.(*pb.GetSprintRequest) | 		req := request.(*pb.GetSprintRequest) | ||||||
| 		rep, err := svc.GetSprint(ctx, req) | 		rep, err := svc.GetSprint(ctx, req) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return &pb.GetSprintReply{ErrMsg: err.Error()}, err | 			return &pb.GetSprintResponse{ErrMsg: err.Error()}, err | ||||||
| 		} | 		} | ||||||
| 		return rep, nil | 		return rep, nil | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -1,11 +1,11 @@ | |||||||
| package sprint_transportgrpc | package sprint_grpctransport | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
|  |  | ||||||
| 	grpctransport "github.com/go-kit/kit/transport/grpc" | 	grpctransport "github.com/go-kit/kit/transport/grpc" | ||||||
| 	pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/sprint" | 	pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/sprint" | ||||||
| 	endpoint "github.com/moul/protoc-gen-gotemplate/examples/go-kit/sprint/gen/endpoints" | 	endpoint "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/sprint/gen/endpoints" | ||||||
| 	context "golang.org/x/net/context" | 	context "golang.org/x/net/context" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| @@ -21,7 +21,7 @@ func MakeGRPCServer(ctx context.Context, endpoints endpoint.Endpoints) pb.Sprint | |||||||
| 			endpoints.AddSprintEndpoint, | 			endpoints.AddSprintEndpoint, | ||||||
| 			decodeAddSprintRequest, | 			decodeAddSprintRequest, | ||||||
| 			encodeAddSprintResponse, | 			encodeAddSprintResponse, | ||||||
| 			options, | 			options..., | ||||||
| 		), | 		), | ||||||
|  |  | ||||||
| 		closesprint: grpctransport.NewServer( | 		closesprint: grpctransport.NewServer( | ||||||
| @@ -29,7 +29,7 @@ func MakeGRPCServer(ctx context.Context, endpoints endpoint.Endpoints) pb.Sprint | |||||||
| 			endpoints.CloseSprintEndpoint, | 			endpoints.CloseSprintEndpoint, | ||||||
| 			decodeCloseSprintRequest, | 			decodeCloseSprintRequest, | ||||||
| 			encodeCloseSprintResponse, | 			encodeCloseSprintResponse, | ||||||
| 			options, | 			options..., | ||||||
| 		), | 		), | ||||||
|  |  | ||||||
| 		getsprint: grpctransport.NewServer( | 		getsprint: grpctransport.NewServer( | ||||||
| @@ -37,7 +37,7 @@ func MakeGRPCServer(ctx context.Context, endpoints endpoint.Endpoints) pb.Sprint | |||||||
| 			endpoints.GetSprintEndpoint, | 			endpoints.GetSprintEndpoint, | ||||||
| 			decodeGetSprintRequest, | 			decodeGetSprintRequest, | ||||||
| 			encodeGetSprintResponse, | 			encodeGetSprintResponse, | ||||||
| 			options, | 			options..., | ||||||
| 		), | 		), | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| @@ -50,12 +50,12 @@ type grpcServer struct { | |||||||
| 	getsprint grpctransport.Handler | 	getsprint grpctransport.Handler | ||||||
| } | } | ||||||
|  |  | ||||||
| func (s *grpcServer) AddSprint(ctx context.Context, req *pb.AddSprintRequest) (*pb.AddSprintReply, error) { | func (s *grpcServer) AddSprint(ctx context.Context, req *pb.AddSprintRequest) (*pb.AddSprintResponse, error) { | ||||||
| 	_, rep, err := s.addsprint.ServeGRPC(ctx, req) | 	_, rep, err := s.addsprint.ServeGRPC(ctx, req) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
| 	} | 	} | ||||||
| 	return rep.(*pb.AddSprintReply), nil | 	return rep.(*pb.AddSprintResponse), nil | ||||||
| } | } | ||||||
|  |  | ||||||
| func decodeAddSprintRequest(ctx context.Context, grpcReq interface{}) (interface{}, error) { | func decodeAddSprintRequest(ctx context.Context, grpcReq interface{}) (interface{}, error) { | ||||||
| @@ -63,16 +63,16 @@ func decodeAddSprintRequest(ctx context.Context, grpcReq interface{}) (interface | |||||||
| } | } | ||||||
|  |  | ||||||
| func encodeAddSprintResponse(ctx context.Context, response interface{}) (interface{}, error) { | func encodeAddSprintResponse(ctx context.Context, response interface{}) (interface{}, error) { | ||||||
| 	resp := response.(*pb.AddSprintReply) | 	resp := response.(*pb.AddSprintResponse) | ||||||
| 	return resp, nil | 	return resp, nil | ||||||
| } | } | ||||||
|  |  | ||||||
| func (s *grpcServer) CloseSprint(ctx context.Context, req *pb.CloseSprintRequest) (*pb.CloseSprintReply, error) { | func (s *grpcServer) CloseSprint(ctx context.Context, req *pb.CloseSprintRequest) (*pb.CloseSprintResponse, error) { | ||||||
| 	_, rep, err := s.closesprint.ServeGRPC(ctx, req) | 	_, rep, err := s.closesprint.ServeGRPC(ctx, req) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
| 	} | 	} | ||||||
| 	return rep.(*pb.CloseSprintReply), nil | 	return rep.(*pb.CloseSprintResponse), nil | ||||||
| } | } | ||||||
|  |  | ||||||
| func decodeCloseSprintRequest(ctx context.Context, grpcReq interface{}) (interface{}, error) { | func decodeCloseSprintRequest(ctx context.Context, grpcReq interface{}) (interface{}, error) { | ||||||
| @@ -80,16 +80,16 @@ func decodeCloseSprintRequest(ctx context.Context, grpcReq interface{}) (interfa | |||||||
| } | } | ||||||
|  |  | ||||||
| func encodeCloseSprintResponse(ctx context.Context, response interface{}) (interface{}, error) { | func encodeCloseSprintResponse(ctx context.Context, response interface{}) (interface{}, error) { | ||||||
| 	resp := response.(*pb.CloseSprintReply) | 	resp := response.(*pb.CloseSprintResponse) | ||||||
| 	return resp, nil | 	return resp, nil | ||||||
| } | } | ||||||
|  |  | ||||||
| func (s *grpcServer) GetSprint(ctx context.Context, req *pb.GetSprintRequest) (*pb.GetSprintReply, error) { | func (s *grpcServer) GetSprint(ctx context.Context, req *pb.GetSprintRequest) (*pb.GetSprintResponse, error) { | ||||||
| 	_, rep, err := s.getsprint.ServeGRPC(ctx, req) | 	_, rep, err := s.getsprint.ServeGRPC(ctx, req) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
| 	} | 	} | ||||||
| 	return rep.(*pb.GetSprintReply), nil | 	return rep.(*pb.GetSprintResponse), nil | ||||||
| } | } | ||||||
|  |  | ||||||
| func decodeGetSprintRequest(ctx context.Context, grpcReq interface{}) (interface{}, error) { | func decodeGetSprintRequest(ctx context.Context, grpcReq interface{}) (interface{}, error) { | ||||||
| @@ -97,6 +97,6 @@ func decodeGetSprintRequest(ctx context.Context, grpcReq interface{}) (interface | |||||||
| } | } | ||||||
|  |  | ||||||
| func encodeGetSprintResponse(ctx context.Context, response interface{}) (interface{}, error) { | func encodeGetSprintResponse(ctx context.Context, response interface{}) (interface{}, error) { | ||||||
| 	resp := response.(*pb.GetSprintReply) | 	resp := response.(*pb.GetSprintResponse) | ||||||
| 	return resp, nil | 	return resp, nil | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| package sprint_transporthttp | package sprint_httptransport | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"encoding/json" | 	"encoding/json" | ||||||
| @@ -9,7 +9,7 @@ import ( | |||||||
| 	gokit_endpoint "github.com/go-kit/kit/endpoint" | 	gokit_endpoint "github.com/go-kit/kit/endpoint" | ||||||
| 	httptransport "github.com/go-kit/kit/transport/http" | 	httptransport "github.com/go-kit/kit/transport/http" | ||||||
| 	pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/sprint" | 	pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/sprint" | ||||||
| 	endpoints "github.com/moul/protoc-gen-gotemplate/examples/go-kit/sprint/gen/endpoints" | 	endpoints "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/sprint/gen/endpoints" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| func MakeAddSprintHandler(ctx context.Context, svc pb.SprintServiceServer, endpoint gokit_endpoint.Endpoint) *httptransport.Server { | func MakeAddSprintHandler(ctx context.Context, svc pb.SprintServiceServer, endpoint gokit_endpoint.Endpoint) *httptransport.Server { | ||||||
| @@ -18,7 +18,7 @@ func MakeAddSprintHandler(ctx context.Context, svc pb.SprintServiceServer, endpo | |||||||
| 		endpoint, | 		endpoint, | ||||||
| 		decodeAddSprintRequest, | 		decodeAddSprintRequest, | ||||||
| 		encodeAddSprintResponse, | 		encodeAddSprintResponse, | ||||||
| 		append([]httptransport.ServerOption{}, httptransport.ServerBefore(jwt.ToHTTPContext()))..., | 		[]httptransport.ServerOption{}..., | ||||||
| 	) | 	) | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -40,7 +40,7 @@ func MakeCloseSprintHandler(ctx context.Context, svc pb.SprintServiceServer, end | |||||||
| 		endpoint, | 		endpoint, | ||||||
| 		decodeCloseSprintRequest, | 		decodeCloseSprintRequest, | ||||||
| 		encodeCloseSprintResponse, | 		encodeCloseSprintResponse, | ||||||
| 		append([]httptransport.ServerOption{}, httptransport.ServerBefore(jwt.ToHTTPContext()))..., | 		[]httptransport.ServerOption{}..., | ||||||
| 	) | 	) | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -62,7 +62,7 @@ func MakeGetSprintHandler(ctx context.Context, svc pb.SprintServiceServer, endpo | |||||||
| 		endpoint, | 		endpoint, | ||||||
| 		decodeGetSprintRequest, | 		decodeGetSprintRequest, | ||||||
| 		encodeGetSprintResponse, | 		encodeGetSprintResponse, | ||||||
| 		append([]httptransport.ServerOption{}, httptransport.ServerBefore(jwt.ToHTTPContext()))..., | 		[]httptransport.ServerOption{}..., | ||||||
| 	) | 	) | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,151 +0,0 @@ | |||||||
| // Code generated by protoc-gen-gogo. |  | ||||||
| // source: services/sprint/sprint.proto |  | ||||||
| // DO NOT EDIT! |  | ||||||
|  |  | ||||||
| /* |  | ||||||
| Package sprint is a generated protocol buffer package. |  | ||||||
|  |  | ||||||
| It is generated from these files: |  | ||||||
| 	services/sprint/sprint.proto |  | ||||||
|  |  | ||||||
| It has these top-level messages: |  | ||||||
| 	AddSprintRequest |  | ||||||
| 	AddSprintResponse |  | ||||||
| 	CloseSprintRequest |  | ||||||
| 	CloseSprintResponse |  | ||||||
| 	GetSprintRequest |  | ||||||
| 	GetSprintResponse |  | ||||||
| 	Sprint |  | ||||||
| */ |  | ||||||
| package sprint |  | ||||||
|  |  | ||||||
| import proto "github.com/gogo/protobuf/proto" |  | ||||||
| import fmt "fmt" |  | ||||||
| import math "math" |  | ||||||
|  |  | ||||||
| // Reference imports to suppress errors if they are not otherwise used. |  | ||||||
| var _ = proto.Marshal |  | ||||||
| var _ = fmt.Errorf |  | ||||||
| var _ = math.Inf |  | ||||||
|  |  | ||||||
| // This is a compile-time assertion to ensure that this generated file |  | ||||||
| // is compatible with the proto package it is being compiled against. |  | ||||||
| // A compilation error at this line likely means your copy of the |  | ||||||
| // proto package needs to be updated. |  | ||||||
| const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package |  | ||||||
|  |  | ||||||
| type AddSprintRequest struct { |  | ||||||
| 	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func (m *AddSprintRequest) Reset()                    { *m = AddSprintRequest{} } |  | ||||||
| func (m *AddSprintRequest) String() string            { return proto.CompactTextString(m) } |  | ||||||
| func (*AddSprintRequest) ProtoMessage()               {} |  | ||||||
| func (*AddSprintRequest) Descriptor() ([]byte, []int) { return fileDescriptorSprint, []int{0} } |  | ||||||
|  |  | ||||||
| type AddSprintResponse struct { |  | ||||||
| 	Sprint *Sprint `protobuf:"bytes,1,opt,name=sprint" json:"sprint,omitempty"` |  | ||||||
| 	ErrMsg string  `protobuf:"bytes,2,opt,name=err_msg,json=errMsg,proto3" json:"err_msg,omitempty"` |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func (m *AddSprintResponse) Reset()                    { *m = AddSprintResponse{} } |  | ||||||
| func (m *AddSprintResponse) String() string            { return proto.CompactTextString(m) } |  | ||||||
| func (*AddSprintResponse) ProtoMessage()               {} |  | ||||||
| func (*AddSprintResponse) Descriptor() ([]byte, []int) { return fileDescriptorSprint, []int{1} } |  | ||||||
|  |  | ||||||
| func (m *AddSprintResponse) GetSprint() *Sprint { |  | ||||||
| 	if m != nil { |  | ||||||
| 		return m.Sprint |  | ||||||
| 	} |  | ||||||
| 	return nil |  | ||||||
| } |  | ||||||
|  |  | ||||||
| type CloseSprintRequest struct { |  | ||||||
| 	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func (m *CloseSprintRequest) Reset()                    { *m = CloseSprintRequest{} } |  | ||||||
| func (m *CloseSprintRequest) String() string            { return proto.CompactTextString(m) } |  | ||||||
| func (*CloseSprintRequest) ProtoMessage()               {} |  | ||||||
| func (*CloseSprintRequest) Descriptor() ([]byte, []int) { return fileDescriptorSprint, []int{2} } |  | ||||||
|  |  | ||||||
| type CloseSprintResponse struct { |  | ||||||
| 	ErrMsg string `protobuf:"bytes,1,opt,name=err_msg,json=errMsg,proto3" json:"err_msg,omitempty"` |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func (m *CloseSprintResponse) Reset()                    { *m = CloseSprintResponse{} } |  | ||||||
| func (m *CloseSprintResponse) String() string            { return proto.CompactTextString(m) } |  | ||||||
| func (*CloseSprintResponse) ProtoMessage()               {} |  | ||||||
| func (*CloseSprintResponse) Descriptor() ([]byte, []int) { return fileDescriptorSprint, []int{3} } |  | ||||||
|  |  | ||||||
| type GetSprintRequest struct { |  | ||||||
| 	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func (m *GetSprintRequest) Reset()                    { *m = GetSprintRequest{} } |  | ||||||
| func (m *GetSprintRequest) String() string            { return proto.CompactTextString(m) } |  | ||||||
| func (*GetSprintRequest) ProtoMessage()               {} |  | ||||||
| func (*GetSprintRequest) Descriptor() ([]byte, []int) { return fileDescriptorSprint, []int{4} } |  | ||||||
|  |  | ||||||
| type GetSprintResponse struct { |  | ||||||
| 	Sprint *Sprint `protobuf:"bytes,1,opt,name=sprint" json:"sprint,omitempty"` |  | ||||||
| 	ErrMsg string  `protobuf:"bytes,2,opt,name=err_msg,json=errMsg,proto3" json:"err_msg,omitempty"` |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func (m *GetSprintResponse) Reset()                    { *m = GetSprintResponse{} } |  | ||||||
| func (m *GetSprintResponse) String() string            { return proto.CompactTextString(m) } |  | ||||||
| func (*GetSprintResponse) ProtoMessage()               {} |  | ||||||
| func (*GetSprintResponse) Descriptor() ([]byte, []int) { return fileDescriptorSprint, []int{5} } |  | ||||||
|  |  | ||||||
| func (m *GetSprintResponse) GetSprint() *Sprint { |  | ||||||
| 	if m != nil { |  | ||||||
| 		return m.Sprint |  | ||||||
| 	} |  | ||||||
| 	return nil |  | ||||||
| } |  | ||||||
|  |  | ||||||
| type Sprint struct { |  | ||||||
| 	Id        string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` |  | ||||||
| 	CreatedAt uint32 `protobuf:"varint,2,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` |  | ||||||
| 	Name      string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func (m *Sprint) Reset()                    { *m = Sprint{} } |  | ||||||
| func (m *Sprint) String() string            { return proto.CompactTextString(m) } |  | ||||||
| func (*Sprint) ProtoMessage()               {} |  | ||||||
| func (*Sprint) Descriptor() ([]byte, []int) { return fileDescriptorSprint, []int{6} } |  | ||||||
|  |  | ||||||
| func init() { |  | ||||||
| 	proto.RegisterType((*AddSprintRequest)(nil), "sprint.AddSprintRequest") |  | ||||||
| 	proto.RegisterType((*AddSprintResponse)(nil), "sprint.AddSprintResponse") |  | ||||||
| 	proto.RegisterType((*CloseSprintRequest)(nil), "sprint.CloseSprintRequest") |  | ||||||
| 	proto.RegisterType((*CloseSprintResponse)(nil), "sprint.CloseSprintResponse") |  | ||||||
| 	proto.RegisterType((*GetSprintRequest)(nil), "sprint.GetSprintRequest") |  | ||||||
| 	proto.RegisterType((*GetSprintResponse)(nil), "sprint.GetSprintResponse") |  | ||||||
| 	proto.RegisterType((*Sprint)(nil), "sprint.Sprint") |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func init() { proto.RegisterFile("services/sprint/sprint.proto", fileDescriptorSprint) } |  | ||||||
|  |  | ||||||
| var fileDescriptorSprint = []byte{ |  | ||||||
| 	// 290 bytes of a gzipped FileDescriptorProto |  | ||||||
| 	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xac, 0x52, 0x4d, 0x4b, 0xc3, 0x40, |  | ||||||
| 	0x10, 0x6d, 0xaa, 0x44, 0x32, 0xa5, 0xa5, 0x1d, 0x0f, 0xc6, 0xa8, 0x20, 0x8b, 0x14, 0x4f, 0x11, |  | ||||||
| 	0xea, 0x2f, 0x68, 0x3d, 0x28, 0x88, 0x97, 0xb4, 0xf7, 0x12, 0xbb, 0x43, 0x09, 0xd8, 0x24, 0xee, |  | ||||||
| 	0xac, 0xfe, 0x5f, 0xff, 0x89, 0xb0, 0xbb, 0xcd, 0x57, 0x8b, 0x27, 0x4f, 0xc9, 0xec, 0xbc, 0x7d, |  | ||||||
| 	0x6f, 0xe6, 0xbd, 0x85, 0x6b, 0x26, 0xf5, 0x9d, 0x6d, 0x88, 0x1f, 0xb8, 0x54, 0x59, 0xae, 0xdd, |  | ||||||
| 	0x27, 0x2e, 0x55, 0xa1, 0x0b, 0xf4, 0x6d, 0x25, 0xa6, 0x30, 0x9e, 0x4b, 0xb9, 0x34, 0x45, 0x42, |  | ||||||
| 	0x9f, 0x5f, 0xc4, 0x1a, 0x11, 0x4e, 0xf3, 0x74, 0x47, 0xa1, 0x77, 0xeb, 0xdd, 0x07, 0x89, 0xf9, |  | ||||||
| 	0x17, 0x2b, 0x98, 0x34, 0x70, 0x5c, 0x16, 0x39, 0x13, 0x4e, 0xc1, 0xd1, 0x18, 0xe8, 0x60, 0x36, |  | ||||||
| 	0x8a, 0x9d, 0x86, 0xc3, 0xb9, 0x2e, 0x5e, 0xc0, 0x19, 0x29, 0xb5, 0xde, 0xf1, 0x36, 0xec, 0x1b, |  | ||||||
| 	0x4e, 0x9f, 0x94, 0x7a, 0xe3, 0xad, 0xb8, 0x03, 0x7c, 0xfa, 0x28, 0x98, 0xda, 0xfa, 0x23, 0xe8, |  | ||||||
| 	0x67, 0xd2, 0xa9, 0xf7, 0x33, 0x29, 0x62, 0x38, 0x6f, 0xa1, 0x9c, 0x7a, 0x83, 0xd5, 0x6b, 0xb1, |  | ||||||
| 	0x0a, 0x18, 0x3f, 0x93, 0xfe, 0x9b, 0x73, 0x05, 0x93, 0x06, 0xe6, 0xbf, 0xf6, 0x79, 0x05, 0xdf, |  | ||||||
| 	0x42, 0xbb, 0x7a, 0x78, 0x03, 0xb0, 0x51, 0x94, 0x6a, 0x92, 0xeb, 0x54, 0x9b, 0x5b, 0xc3, 0x24, |  | ||||||
| 	0x70, 0x27, 0xf3, 0xda, 0xf2, 0x93, 0xda, 0xf2, 0xd9, 0x8f, 0x07, 0x43, 0xcb, 0xb6, 0xb4, 0x49, |  | ||||||
| 	0xe2, 0x02, 0x82, 0x2a, 0x04, 0x0c, 0xf7, 0xc3, 0x75, 0xf3, 0x8b, 0x2e, 0x8f, 0x74, 0xec, 0x86, |  | ||||||
| 	0xa2, 0x87, 0x2f, 0x30, 0x68, 0x98, 0x89, 0xd1, 0x1e, 0x7b, 0x98, 0x43, 0x74, 0x75, 0xb4, 0x57, |  | ||||||
| 	0x31, 0x2d, 0x20, 0xa8, 0x2c, 0xac, 0xa7, 0xe9, 0x3a, 0x5f, 0x4f, 0x73, 0xe0, 0xb7, 0xe8, 0xbd, |  | ||||||
| 	0xfb, 0xe6, 0x35, 0x3e, 0xfe, 0x06, 0x00, 0x00, 0xff, 0xff, 0xf0, 0x9e, 0xb2, 0x1e, 0xad, 0x02, |  | ||||||
| 	0x00, 0x00, |  | ||||||
| } |  | ||||||
| @@ -23,6 +23,11 @@ import proto "github.com/gogo/protobuf/proto" | |||||||
| import fmt "fmt" | import fmt "fmt" | ||||||
| import math "math" | import math "math" | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	context "golang.org/x/net/context" | ||||||
|  | 	grpc "google.golang.org/grpc" | ||||||
|  | ) | ||||||
|  |  | ||||||
| // Reference imports to suppress errors if they are not otherwise used. | // Reference imports to suppress errors if they are not otherwise used. | ||||||
| var _ = proto.Marshal | var _ = proto.Marshal | ||||||
| var _ = fmt.Errorf | var _ = fmt.Errorf | ||||||
| @@ -43,6 +48,13 @@ func (m *AddSprintRequest) String() string            { return proto.CompactText | |||||||
| func (*AddSprintRequest) ProtoMessage()               {} | func (*AddSprintRequest) ProtoMessage()               {} | ||||||
| func (*AddSprintRequest) Descriptor() ([]byte, []int) { return fileDescriptorSprint, []int{0} } | func (*AddSprintRequest) Descriptor() ([]byte, []int) { return fileDescriptorSprint, []int{0} } | ||||||
|  |  | ||||||
|  | func (m *AddSprintRequest) GetName() string { | ||||||
|  | 	if m != nil { | ||||||
|  | 		return m.Name | ||||||
|  | 	} | ||||||
|  | 	return "" | ||||||
|  | } | ||||||
|  |  | ||||||
| type AddSprintResponse struct { | type AddSprintResponse struct { | ||||||
| 	Sprint *Sprint `protobuf:"bytes,1,opt,name=sprint" json:"sprint,omitempty"` | 	Sprint *Sprint `protobuf:"bytes,1,opt,name=sprint" json:"sprint,omitempty"` | ||||||
| 	ErrMsg string  `protobuf:"bytes,2,opt,name=err_msg,json=errMsg,proto3" json:"err_msg,omitempty"` | 	ErrMsg string  `protobuf:"bytes,2,opt,name=err_msg,json=errMsg,proto3" json:"err_msg,omitempty"` | ||||||
| @@ -60,6 +72,13 @@ func (m *AddSprintResponse) GetSprint() *Sprint { | |||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
|  |  | ||||||
|  | func (m *AddSprintResponse) GetErrMsg() string { | ||||||
|  | 	if m != nil { | ||||||
|  | 		return m.ErrMsg | ||||||
|  | 	} | ||||||
|  | 	return "" | ||||||
|  | } | ||||||
|  |  | ||||||
| type CloseSprintRequest struct { | type CloseSprintRequest struct { | ||||||
| 	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` | 	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` | ||||||
| } | } | ||||||
| @@ -69,6 +88,13 @@ func (m *CloseSprintRequest) String() string            { return proto.CompactTe | |||||||
| func (*CloseSprintRequest) ProtoMessage()               {} | func (*CloseSprintRequest) ProtoMessage()               {} | ||||||
| func (*CloseSprintRequest) Descriptor() ([]byte, []int) { return fileDescriptorSprint, []int{2} } | func (*CloseSprintRequest) Descriptor() ([]byte, []int) { return fileDescriptorSprint, []int{2} } | ||||||
|  |  | ||||||
|  | func (m *CloseSprintRequest) GetId() string { | ||||||
|  | 	if m != nil { | ||||||
|  | 		return m.Id | ||||||
|  | 	} | ||||||
|  | 	return "" | ||||||
|  | } | ||||||
|  |  | ||||||
| type CloseSprintResponse struct { | type CloseSprintResponse struct { | ||||||
| 	ErrMsg string `protobuf:"bytes,1,opt,name=err_msg,json=errMsg,proto3" json:"err_msg,omitempty"` | 	ErrMsg string `protobuf:"bytes,1,opt,name=err_msg,json=errMsg,proto3" json:"err_msg,omitempty"` | ||||||
| } | } | ||||||
| @@ -78,6 +104,13 @@ func (m *CloseSprintResponse) String() string            { return proto.CompactT | |||||||
| func (*CloseSprintResponse) ProtoMessage()               {} | func (*CloseSprintResponse) ProtoMessage()               {} | ||||||
| func (*CloseSprintResponse) Descriptor() ([]byte, []int) { return fileDescriptorSprint, []int{3} } | func (*CloseSprintResponse) Descriptor() ([]byte, []int) { return fileDescriptorSprint, []int{3} } | ||||||
|  |  | ||||||
|  | func (m *CloseSprintResponse) GetErrMsg() string { | ||||||
|  | 	if m != nil { | ||||||
|  | 		return m.ErrMsg | ||||||
|  | 	} | ||||||
|  | 	return "" | ||||||
|  | } | ||||||
|  |  | ||||||
| type GetSprintRequest struct { | type GetSprintRequest struct { | ||||||
| 	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` | 	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` | ||||||
| } | } | ||||||
| @@ -87,6 +120,13 @@ func (m *GetSprintRequest) String() string            { return proto.CompactText | |||||||
| func (*GetSprintRequest) ProtoMessage()               {} | func (*GetSprintRequest) ProtoMessage()               {} | ||||||
| func (*GetSprintRequest) Descriptor() ([]byte, []int) { return fileDescriptorSprint, []int{4} } | func (*GetSprintRequest) Descriptor() ([]byte, []int) { return fileDescriptorSprint, []int{4} } | ||||||
|  |  | ||||||
|  | func (m *GetSprintRequest) GetId() string { | ||||||
|  | 	if m != nil { | ||||||
|  | 		return m.Id | ||||||
|  | 	} | ||||||
|  | 	return "" | ||||||
|  | } | ||||||
|  |  | ||||||
| type GetSprintResponse struct { | type GetSprintResponse struct { | ||||||
| 	Sprint *Sprint `protobuf:"bytes,1,opt,name=sprint" json:"sprint,omitempty"` | 	Sprint *Sprint `protobuf:"bytes,1,opt,name=sprint" json:"sprint,omitempty"` | ||||||
| 	ErrMsg string  `protobuf:"bytes,2,opt,name=err_msg,json=errMsg,proto3" json:"err_msg,omitempty"` | 	ErrMsg string  `protobuf:"bytes,2,opt,name=err_msg,json=errMsg,proto3" json:"err_msg,omitempty"` | ||||||
| @@ -104,6 +144,13 @@ func (m *GetSprintResponse) GetSprint() *Sprint { | |||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
|  |  | ||||||
|  | func (m *GetSprintResponse) GetErrMsg() string { | ||||||
|  | 	if m != nil { | ||||||
|  | 		return m.ErrMsg | ||||||
|  | 	} | ||||||
|  | 	return "" | ||||||
|  | } | ||||||
|  |  | ||||||
| type Sprint struct { | type Sprint struct { | ||||||
| 	Id        string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` | 	Id        string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` | ||||||
| 	CreatedAt uint32 `protobuf:"varint,2,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` | 	CreatedAt uint32 `protobuf:"varint,2,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` | ||||||
| @@ -115,6 +162,27 @@ func (m *Sprint) String() string            { return proto.CompactTextString(m) | |||||||
| func (*Sprint) ProtoMessage()               {} | func (*Sprint) ProtoMessage()               {} | ||||||
| func (*Sprint) Descriptor() ([]byte, []int) { return fileDescriptorSprint, []int{6} } | func (*Sprint) Descriptor() ([]byte, []int) { return fileDescriptorSprint, []int{6} } | ||||||
|  |  | ||||||
|  | func (m *Sprint) GetId() string { | ||||||
|  | 	if m != nil { | ||||||
|  | 		return m.Id | ||||||
|  | 	} | ||||||
|  | 	return "" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (m *Sprint) GetCreatedAt() uint32 { | ||||||
|  | 	if m != nil { | ||||||
|  | 		return m.CreatedAt | ||||||
|  | 	} | ||||||
|  | 	return 0 | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (m *Sprint) GetName() string { | ||||||
|  | 	if m != nil { | ||||||
|  | 		return m.Name | ||||||
|  | 	} | ||||||
|  | 	return "" | ||||||
|  | } | ||||||
|  |  | ||||||
| func init() { | func init() { | ||||||
| 	proto.RegisterType((*AddSprintRequest)(nil), "sprint.AddSprintRequest") | 	proto.RegisterType((*AddSprintRequest)(nil), "sprint.AddSprintRequest") | ||||||
| 	proto.RegisterType((*AddSprintResponse)(nil), "sprint.AddSprintResponse") | 	proto.RegisterType((*AddSprintResponse)(nil), "sprint.AddSprintResponse") | ||||||
| @@ -125,6 +193,144 @@ func init() { | |||||||
| 	proto.RegisterType((*Sprint)(nil), "sprint.Sprint") | 	proto.RegisterType((*Sprint)(nil), "sprint.Sprint") | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // Reference imports to suppress errors if they are not otherwise used. | ||||||
|  | var _ context.Context | ||||||
|  | var _ grpc.ClientConn | ||||||
|  |  | ||||||
|  | // This is a compile-time assertion to ensure that this generated file | ||||||
|  | // is compatible with the grpc package it is being compiled against. | ||||||
|  | const _ = grpc.SupportPackageIsVersion4 | ||||||
|  |  | ||||||
|  | // Client API for SprintService service | ||||||
|  |  | ||||||
|  | type SprintServiceClient interface { | ||||||
|  | 	AddSprint(ctx context.Context, in *AddSprintRequest, opts ...grpc.CallOption) (*AddSprintResponse, error) | ||||||
|  | 	CloseSprint(ctx context.Context, in *CloseSprintRequest, opts ...grpc.CallOption) (*CloseSprintResponse, error) | ||||||
|  | 	GetSprint(ctx context.Context, in *GetSprintRequest, opts ...grpc.CallOption) (*GetSprintResponse, error) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | type sprintServiceClient struct { | ||||||
|  | 	cc *grpc.ClientConn | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func NewSprintServiceClient(cc *grpc.ClientConn) SprintServiceClient { | ||||||
|  | 	return &sprintServiceClient{cc} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (c *sprintServiceClient) AddSprint(ctx context.Context, in *AddSprintRequest, opts ...grpc.CallOption) (*AddSprintResponse, error) { | ||||||
|  | 	out := new(AddSprintResponse) | ||||||
|  | 	err := grpc.Invoke(ctx, "/sprint.SprintService/AddSprint", in, out, c.cc, opts...) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, err | ||||||
|  | 	} | ||||||
|  | 	return out, nil | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (c *sprintServiceClient) CloseSprint(ctx context.Context, in *CloseSprintRequest, opts ...grpc.CallOption) (*CloseSprintResponse, error) { | ||||||
|  | 	out := new(CloseSprintResponse) | ||||||
|  | 	err := grpc.Invoke(ctx, "/sprint.SprintService/CloseSprint", in, out, c.cc, opts...) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, err | ||||||
|  | 	} | ||||||
|  | 	return out, nil | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (c *sprintServiceClient) GetSprint(ctx context.Context, in *GetSprintRequest, opts ...grpc.CallOption) (*GetSprintResponse, error) { | ||||||
|  | 	out := new(GetSprintResponse) | ||||||
|  | 	err := grpc.Invoke(ctx, "/sprint.SprintService/GetSprint", in, out, c.cc, opts...) | ||||||
|  | 	if err != nil { | ||||||
|  | 		return nil, err | ||||||
|  | 	} | ||||||
|  | 	return out, nil | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Server API for SprintService service | ||||||
|  |  | ||||||
|  | type SprintServiceServer interface { | ||||||
|  | 	AddSprint(context.Context, *AddSprintRequest) (*AddSprintResponse, error) | ||||||
|  | 	CloseSprint(context.Context, *CloseSprintRequest) (*CloseSprintResponse, error) | ||||||
|  | 	GetSprint(context.Context, *GetSprintRequest) (*GetSprintResponse, error) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func RegisterSprintServiceServer(s *grpc.Server, srv SprintServiceServer) { | ||||||
|  | 	s.RegisterService(&_SprintService_serviceDesc, srv) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func _SprintService_AddSprint_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { | ||||||
|  | 	in := new(AddSprintRequest) | ||||||
|  | 	if err := dec(in); err != nil { | ||||||
|  | 		return nil, err | ||||||
|  | 	} | ||||||
|  | 	if interceptor == nil { | ||||||
|  | 		return srv.(SprintServiceServer).AddSprint(ctx, in) | ||||||
|  | 	} | ||||||
|  | 	info := &grpc.UnaryServerInfo{ | ||||||
|  | 		Server:     srv, | ||||||
|  | 		FullMethod: "/sprint.SprintService/AddSprint", | ||||||
|  | 	} | ||||||
|  | 	handler := func(ctx context.Context, req interface{}) (interface{}, error) { | ||||||
|  | 		return srv.(SprintServiceServer).AddSprint(ctx, req.(*AddSprintRequest)) | ||||||
|  | 	} | ||||||
|  | 	return interceptor(ctx, in, info, handler) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func _SprintService_CloseSprint_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { | ||||||
|  | 	in := new(CloseSprintRequest) | ||||||
|  | 	if err := dec(in); err != nil { | ||||||
|  | 		return nil, err | ||||||
|  | 	} | ||||||
|  | 	if interceptor == nil { | ||||||
|  | 		return srv.(SprintServiceServer).CloseSprint(ctx, in) | ||||||
|  | 	} | ||||||
|  | 	info := &grpc.UnaryServerInfo{ | ||||||
|  | 		Server:     srv, | ||||||
|  | 		FullMethod: "/sprint.SprintService/CloseSprint", | ||||||
|  | 	} | ||||||
|  | 	handler := func(ctx context.Context, req interface{}) (interface{}, error) { | ||||||
|  | 		return srv.(SprintServiceServer).CloseSprint(ctx, req.(*CloseSprintRequest)) | ||||||
|  | 	} | ||||||
|  | 	return interceptor(ctx, in, info, handler) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func _SprintService_GetSprint_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { | ||||||
|  | 	in := new(GetSprintRequest) | ||||||
|  | 	if err := dec(in); err != nil { | ||||||
|  | 		return nil, err | ||||||
|  | 	} | ||||||
|  | 	if interceptor == nil { | ||||||
|  | 		return srv.(SprintServiceServer).GetSprint(ctx, in) | ||||||
|  | 	} | ||||||
|  | 	info := &grpc.UnaryServerInfo{ | ||||||
|  | 		Server:     srv, | ||||||
|  | 		FullMethod: "/sprint.SprintService/GetSprint", | ||||||
|  | 	} | ||||||
|  | 	handler := func(ctx context.Context, req interface{}) (interface{}, error) { | ||||||
|  | 		return srv.(SprintServiceServer).GetSprint(ctx, req.(*GetSprintRequest)) | ||||||
|  | 	} | ||||||
|  | 	return interceptor(ctx, in, info, handler) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | var _SprintService_serviceDesc = grpc.ServiceDesc{ | ||||||
|  | 	ServiceName: "sprint.SprintService", | ||||||
|  | 	HandlerType: (*SprintServiceServer)(nil), | ||||||
|  | 	Methods: []grpc.MethodDesc{ | ||||||
|  | 		{ | ||||||
|  | 			MethodName: "AddSprint", | ||||||
|  | 			Handler:    _SprintService_AddSprint_Handler, | ||||||
|  | 		}, | ||||||
|  | 		{ | ||||||
|  | 			MethodName: "CloseSprint", | ||||||
|  | 			Handler:    _SprintService_CloseSprint_Handler, | ||||||
|  | 		}, | ||||||
|  | 		{ | ||||||
|  | 			MethodName: "GetSprint", | ||||||
|  | 			Handler:    _SprintService_GetSprint_Handler, | ||||||
|  | 		}, | ||||||
|  | 	}, | ||||||
|  | 	Streams:  []grpc.StreamDesc{}, | ||||||
|  | 	Metadata: "services/sprint/sprint.proto", | ||||||
|  | } | ||||||
|  |  | ||||||
| func init() { proto.RegisterFile("services/sprint/sprint.proto", fileDescriptorSprint) } | func init() { proto.RegisterFile("services/sprint/sprint.proto", fileDescriptorSprint) } | ||||||
|  |  | ||||||
| var fileDescriptorSprint = []byte{ | var fileDescriptorSprint = []byte{ | ||||||
|   | |||||||
							
								
								
									
										27
									
								
								examples/go-kit/services/sprint/svc/service.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								examples/go-kit/services/sprint/svc/service.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,27 @@ | |||||||
|  | package sprintsvc | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"fmt" | ||||||
|  |  | ||||||
|  | 	"golang.org/x/net/context" | ||||||
|  |  | ||||||
|  | 	pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/sprint" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | type Service struct{} | ||||||
|  |  | ||||||
|  | func New() pb.SprintServiceServer { | ||||||
|  | 	return &Service{} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (svc *Service) AddSprint(ctx context.Context, in *pb.AddSprintRequest) (*pb.AddSprintResponse, error) { | ||||||
|  | 	return nil, fmt.Errorf("not implemented") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (svc *Service) CloseSprint(ctx context.Context, in *pb.CloseSprintRequest) (*pb.CloseSprintResponse, error) { | ||||||
|  | 	return nil, fmt.Errorf("not implemented") | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (svc *Service) GetSprint(ctx context.Context, in *pb.GetSprintRequest) (*pb.GetSprintResponse, error) { | ||||||
|  | 	return nil, fmt.Errorf("not implemented") | ||||||
|  | } | ||||||
| @@ -23,7 +23,7 @@ func (e *Endpoints){{.Name}}(ctx context.Context, in *pb.{{.Name}}Request) (*pb. | |||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return &pb.{{.Name}}Response{ErrMsg: err.Error()}, err | 		return &pb.{{.Name}}Response{ErrMsg: err.Error()}, err | ||||||
| 	} | 	} | ||||||
| 	return out.(*pb.{{.Name}}Reply), err | 	return out.(*pb.{{.Name}}Response), err | ||||||
| } | } | ||||||
| {{end}} | {{end}} | ||||||
|  |  | ||||||
| @@ -33,7 +33,7 @@ func Make{{.Name}}Endpoint(svc pb.{{$file.Package | title}}ServiceServer) endpoi | |||||||
| 		req := request.(*pb.{{.Name}}Request) | 		req := request.(*pb.{{.Name}}Request) | ||||||
| 		rep, err := svc.{{.Name}}(ctx, req) | 		rep, err := svc.{{.Name}}(ctx, req) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return &pb.{{.Name}}Reply{ErrMsg: err.Error()}, err | 			return &pb.{{.Name}}Response{ErrMsg: err.Error()}, err | ||||||
| 		} | 		} | ||||||
| 		return rep, nil | 		return rep, nil | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| package {{.File.Package}}_transportgrpc | package {{.File.Package}}_grpctransport | ||||||
|  |  | ||||||
| {{$file := .File}} | {{$file := .File}} | ||||||
|  |  | ||||||
| @@ -8,7 +8,7 @@ import ( | |||||||
| 	context "golang.org/x/net/context" | 	context "golang.org/x/net/context" | ||||||
| 	pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/{{.File.Package}}" | 	pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/{{.File.Package}}" | ||||||
| 	grpctransport "github.com/go-kit/kit/transport/grpc" | 	grpctransport "github.com/go-kit/kit/transport/grpc" | ||||||
| 	endpoint "github.com/moul/protoc-gen-gotemplate/examples/go-kit/{{.File.Package}}/gen/endpoints" | 	endpoint "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/{{.File.Package}}/gen/endpoints" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| // avoid import errors | // avoid import errors | ||||||
| @@ -25,7 +25,7 @@ func MakeGRPCServer(ctx context.Context, endpoints endpoint.Endpoints) pb.{{.Fil | |||||||
| 			endpoints.{{.Name}}Endpoint, | 			endpoints.{{.Name}}Endpoint, | ||||||
| 			decode{{.Name}}Request, | 			decode{{.Name}}Request, | ||||||
| 			encode{{.Name}}Response, | 			encode{{.Name}}Response, | ||||||
| 			options, | 			options..., | ||||||
| 		), | 		), | ||||||
|                 {{end}} |                 {{end}} | ||||||
| 		{{end}} | 		{{end}} | ||||||
| @@ -40,12 +40,12 @@ type grpcServer struct { | |||||||
| } | } | ||||||
|  |  | ||||||
| {{range .Service.Method}} | {{range .Service.Method}} | ||||||
| func (s *grpcServer) {{.Name}}(ctx context.Context, req *pb.{{.Name}}Request) (*pb.{{.Name}}Reply, error) { | func (s *grpcServer) {{.Name}}(ctx context.Context, req *pb.{{.Name}}Request) (*pb.{{.Name}}Response, error) { | ||||||
| 	_, rep, err := s.{{.Name | lower}}.ServeGRPC(ctx, req) | 	_, rep, err := s.{{.Name | lower}}.ServeGRPC(ctx, req) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
| 	} | 	} | ||||||
| 	return rep.(*pb.{{.Name}}Reply), nil | 	return rep.(*pb.{{.Name}}Response), nil | ||||||
| } | } | ||||||
|  |  | ||||||
| func decode{{.Name}}Request(ctx context.Context, grpcReq interface{}) (interface{}, error) { | func decode{{.Name}}Request(ctx context.Context, grpcReq interface{}) (interface{}, error) { | ||||||
| @@ -53,7 +53,7 @@ func decode{{.Name}}Request(ctx context.Context, grpcReq interface{}) (interface | |||||||
| } | } | ||||||
|  |  | ||||||
| func encode{{.Name}}Response(ctx context.Context, response interface{}) (interface{}, error) { | func encode{{.Name}}Response(ctx context.Context, response interface{}) (interface{}, error) { | ||||||
| 	resp := response.(*pb.{{.Name}}Reply) | 	resp := response.(*pb.{{.Name}}Response) | ||||||
| 	return resp, nil | 	return resp, nil | ||||||
| } | } | ||||||
| {{end}} | {{end}} | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| package {{.File.Package}}_transporthttp | package {{.File.Package}}_httptransport | ||||||
|  |  | ||||||
| {{$file := .File}} | {{$file := .File}} | ||||||
|  |  | ||||||
| @@ -11,7 +11,7 @@ import ( | |||||||
| 	pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/{{.File.Package}}" | 	pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/{{.File.Package}}" | ||||||
|         gokit_endpoint "github.com/go-kit/kit/endpoint" |         gokit_endpoint "github.com/go-kit/kit/endpoint" | ||||||
| 	httptransport "github.com/go-kit/kit/transport/http" | 	httptransport "github.com/go-kit/kit/transport/http" | ||||||
| 	endpoints "github.com/moul/protoc-gen-gotemplate/examples/go-kit/{{.File.Package}}/gen/endpoints" | 	endpoints "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/{{.File.Package}}/gen/endpoints" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| {{range .Service.Method}} | {{range .Service.Method}} | ||||||
| @@ -21,7 +21,7 @@ func Make{{.Name}}Handler(ctx context.Context, svc pb.{{$file.Package | title}}S | |||||||
| 		endpoint, | 		endpoint, | ||||||
| 		decode{{.Name}}Request, | 		decode{{.Name}}Request, | ||||||
| 		encode{{.Name}}Response, | 		encode{{.Name}}Response, | ||||||
| 		append([]httptransport.ServerOption{}, httptransport.ServerBefore(jwt.ToHTTPContext()))..., |                 []httptransport.ServerOption{}..., | ||||||
| 	) | 	) | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user