Move all generated code in the gen sub-directory
This commit is contained in:
		| @@ -3,6 +3,8 @@ SOURCES :=	$(shell find . -name "*.proto" -not -path ./vendor/\*) | |||||||
| TARGETS_GO :=	$(foreach source, $(SOURCES), $(source)_go) | TARGETS_GO :=	$(foreach source, $(SOURCES), $(source)_go) | ||||||
| TARGETS_TMPL :=	$(foreach source, $(SOURCES), $(source)_tmpl) | TARGETS_TMPL :=	$(foreach source, $(SOURCES), $(source)_tmpl) | ||||||
|  |  | ||||||
|  | service_name =	$(word 2,$(subst /, ,$1)) | ||||||
|  |  | ||||||
| .PHONY: build | .PHONY: build | ||||||
| build: server | build: server | ||||||
|  |  | ||||||
| @@ -11,6 +13,8 @@ server: $(TARGETS_GO) $(TARGETS_TMPL) | |||||||
|  |  | ||||||
| $(TARGETS_GO): %_go: | $(TARGETS_GO): %_go: | ||||||
| 	protoc --gogo_out=plugins=grpc:. "$*" | 	protoc --gogo_out=plugins=grpc:. "$*" | ||||||
|  | 	@mkdir -p services/$(call service_name,$*)/gen/pb | ||||||
|  | 	@mv ./services/$(call service_name,$*)/$(call service_name,$*).pb.go ./services/$(call service_name,$*)/gen/pb/pb.go | ||||||
|  |  | ||||||
| $(TARGETS_TMPL): %_tmpl: | $(TARGETS_TMPL): %_tmpl: | ||||||
| 	@mkdir -p $(dir $*)gen | 	@mkdir -p $(dir $*)gen | ||||||
|   | |||||||
| @@ -13,11 +13,17 @@ import ( | |||||||
| 	"github.com/gorilla/handlers" | 	"github.com/gorilla/handlers" | ||||||
| 	"google.golang.org/grpc" | 	"google.golang.org/grpc" | ||||||
|  |  | ||||||
| 	session_pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/session" | 	session_svc "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_endpoints "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/session/gen/endpoints" | ||||||
|  | 	session_pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/session/gen/pb" | ||||||
| 	session_grpctransport "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/session/gen/transports/grpc" | 	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" | 	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" |  | ||||||
|  | 	sprint_svc "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/sprint" | ||||||
|  | 	sprint_endpoints "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/sprint/gen/endpoints" | ||||||
|  | 	sprint_pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/sprint/gen/pb" | ||||||
|  | 	sprint_grpctransport "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/sprint/gen/transports/grpc" | ||||||
|  | 	sprint_httptransport "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/sprint/gen/transports/http" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| func main() { | func main() { | ||||||
| @@ -34,15 +40,18 @@ func main() { | |||||||
|  |  | ||||||
| 	// initialize services | 	// initialize services | ||||||
| 	{ | 	{ | ||||||
| 		svc := sessionsvc.New() | 		svc := session_svc.New() | ||||||
| 		endpoints := session_endpoints.MakeEndpoints(svc) | 		endpoints := session_endpoints.MakeEndpoints(svc) | ||||||
| 		srv := session_grpctransport.MakeGRPCServer(ctx, endpoints) | 		srv := session_grpctransport.MakeGRPCServer(ctx, endpoints) | ||||||
| 		session_pb.RegisterSessionServiceServer(s, srv) | 		session_pb.RegisterSessionServiceServer(s, srv) | ||||||
| 		session_httptransport.RegisterHandlers(ctx, svc, mux, endpoints) | 		session_httptransport.RegisterHandlers(ctx, svc, mux, endpoints) | ||||||
| 	} | 	} | ||||||
| 	{ | 	{ | ||||||
| 		//svc := sprintsvc.New() | 		svc := sprint_svc.New() | ||||||
|  | 		endpoints := sprint_endpoints.MakeEndpoints(svc) | ||||||
|  | 		srv := sprint_grpctransport.MakeGRPCServer(ctx, endpoints) | ||||||
|  | 		sprint_pb.RegisterSprintServiceServer(s, srv) | ||||||
|  | 		sprint_httptransport.RegisterHandlers(ctx, svc, mux, endpoints) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	// start servers | 	// start servers | ||||||
|   | |||||||
| @@ -3,7 +3,7 @@ package session_endpoints | |||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"github.com/go-kit/kit/endpoint" | 	"github.com/go-kit/kit/endpoint" | ||||||
| 	pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/session" | 	pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/session/gen/pb" | ||||||
| 	context "golang.org/x/net/context" | 	context "golang.org/x/net/context" | ||||||
| ) | ) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -4,8 +4,8 @@ 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" |  | ||||||
| 	endpoint "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/session/gen/endpoints" | 	endpoint "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/session/gen/endpoints" | ||||||
|  | 	pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/session/gen/pb" | ||||||
| 	context "golang.org/x/net/context" | 	context "golang.org/x/net/context" | ||||||
| ) | ) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -8,8 +8,8 @@ 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" |  | ||||||
| 	endpoints "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/session/gen/endpoints" | 	endpoints "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/session/gen/endpoints" | ||||||
|  | 	pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/session/gen/pb" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| 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 { | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ import ( | |||||||
| 
 | 
 | ||||||
| 	"golang.org/x/net/context" | 	"golang.org/x/net/context" | ||||||
| 
 | 
 | ||||||
| 	pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/session" | 	pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/session/gen/pb" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| type Service struct{} | type Service struct{} | ||||||
| @@ -3,7 +3,7 @@ package sprint_endpoints | |||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"github.com/go-kit/kit/endpoint" | 	"github.com/go-kit/kit/endpoint" | ||||||
| 	pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/sprint" | 	pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/sprint/gen/pb" | ||||||
| 	context "golang.org/x/net/context" | 	context "golang.org/x/net/context" | ||||||
| ) | ) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -4,8 +4,8 @@ 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" |  | ||||||
| 	endpoint "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/sprint/gen/endpoints" | 	endpoint "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/sprint/gen/endpoints" | ||||||
|  | 	pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/sprint/gen/pb" | ||||||
| 	context "golang.org/x/net/context" | 	context "golang.org/x/net/context" | ||||||
| ) | ) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -8,8 +8,8 @@ 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" |  | ||||||
| 	endpoints "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/sprint/gen/endpoints" | 	endpoints "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/sprint/gen/endpoints" | ||||||
|  | 	pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/sprint/gen/pb" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| 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 { | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ import ( | |||||||
| 
 | 
 | ||||||
| 	"golang.org/x/net/context" | 	"golang.org/x/net/context" | ||||||
| 
 | 
 | ||||||
| 	pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/sprint" | 	pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/sprint/gen/pb" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| type Service struct{} | type Service struct{} | ||||||
| @@ -5,7 +5,7 @@ package {{.File.Package}}_endpoints | |||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	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}}/gen/pb" | ||||||
| 	"github.com/go-kit/kit/endpoint" | 	"github.com/go-kit/kit/endpoint" | ||||||
| ) | ) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ import ( | |||||||
|         "fmt" |         "fmt" | ||||||
|  |  | ||||||
| 	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}}/gen/pb" | ||||||
| 	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/services/{{.File.Package}}/gen/endpoints" | 	endpoint "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/{{.File.Package}}/gen/endpoints" | ||||||
| ) | ) | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ import ( | |||||||
| 	"encoding/json" | 	"encoding/json" | ||||||
| 	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}}/gen/pb" | ||||||
|         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/services/{{.File.Package}}/gen/endpoints" | 	endpoints "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/{{.File.Package}}/gen/endpoints" | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user