Merge pull request #51 from moul/dev/moul/enable-tests
Enable all tests
This commit is contained in:
commit
266d42dc25
@ -1,8 +1,9 @@
|
|||||||
language: go
|
language: go
|
||||||
go: 1.7.x
|
go: 1.7.x
|
||||||
install:
|
install:
|
||||||
|
- mkdir -p $GOPATH/bin && curl https://glide.sh/get | sh
|
||||||
- wget https://raw.githubusercontent.com/grpc-ecosystem/grpc-gateway/master/.travis/install-protoc.sh && chmod +x install-protoc.sh && ./install-protoc.sh 3.1.0
|
- wget https://raw.githubusercontent.com/grpc-ecosystem/grpc-gateway/master/.travis/install-protoc.sh && chmod +x install-protoc.sh && ./install-protoc.sh 3.1.0
|
||||||
- go get github.com/gogo/protobuf/protoc-gen-gogo
|
- go get -u github.com/golang/protobuf/protoc-gen-go
|
||||||
script:
|
script:
|
||||||
- make install
|
- make install
|
||||||
- make test
|
- make test
|
||||||
|
3
Makefile
3
Makefile
@ -10,6 +10,9 @@ install:
|
|||||||
test: build
|
test: build
|
||||||
cd examples/dummy && make
|
cd examples/dummy && make
|
||||||
cd examples/flow && make
|
cd examples/flow && make
|
||||||
|
cd examples/concat && make
|
||||||
|
cd examples/flow && make
|
||||||
|
cd examples/go-kit && make
|
||||||
|
|
||||||
.PHONY: docker.build
|
.PHONY: docker.build
|
||||||
docker.build:
|
docker.build:
|
||||||
|
1
examples/go-kit/.gitignore
vendored
1
examples/go-kit/.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
|
/vendor/
|
||||||
/server
|
/server
|
||||||
|
@ -9,10 +9,11 @@ service_name = $(word 2,$(subst /, ,$1))
|
|||||||
build: server
|
build: server
|
||||||
|
|
||||||
server: $(TARGETS_GO) $(TARGETS_TMPL)
|
server: $(TARGETS_GO) $(TARGETS_TMPL)
|
||||||
|
glide install
|
||||||
go build -o server .
|
go build -o server .
|
||||||
|
|
||||||
$(TARGETS_GO): %_go:
|
$(TARGETS_GO): %_go:
|
||||||
protoc --gogo_out=plugins=grpc:. "$*"
|
protoc --go_out=plugins=grpc:. "$*"
|
||||||
@mkdir -p services/$(call service_name,$*)/gen/pb
|
@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
|
@mv ./services/$(call service_name,$*)/$(call service_name,$*).pb.go ./services/$(call service_name,$*)/gen/pb/pb.go
|
||||||
|
|
||||||
|
48
examples/go-kit/glide.lock
generated
Normal file
48
examples/go-kit/glide.lock
generated
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
hash: e225ab17b49f8d6601b2bd813d43ad34ee04380d29c278c11919efd454c7b2d7
|
||||||
|
updated: 2017-03-16T17:03:34.437968115+01:00
|
||||||
|
imports:
|
||||||
|
- name: github.com/dgrijalva/jwt-go
|
||||||
|
version: 2268707a8f0843315e2004ee4f1d021dc08baedf
|
||||||
|
- name: github.com/go-kit/kit
|
||||||
|
version: fadad6fffe0466b19df9efd9acde5c9a52df5fa4
|
||||||
|
subpackages:
|
||||||
|
- auth/jwt
|
||||||
|
- endpoint
|
||||||
|
- log
|
||||||
|
- transport/grpc
|
||||||
|
- transport/http
|
||||||
|
- name: github.com/go-logfmt/logfmt
|
||||||
|
version: 390ab7935ee28ec6b286364bba9b4dd6410cb3d5
|
||||||
|
- name: github.com/go-stack/stack
|
||||||
|
version: 100eb0c0a9c5b306ca2fb4f165df21d80ada4b82
|
||||||
|
- name: github.com/golang/protobuf
|
||||||
|
version: c9c7427a2a70d2eb3bafa0ab2dc163e45f143317
|
||||||
|
subpackages:
|
||||||
|
- proto
|
||||||
|
- name: github.com/gorilla/handlers
|
||||||
|
version: 3a5767ca75ece5f7f1440b1d16975247f8d8b221
|
||||||
|
- name: github.com/kr/logfmt
|
||||||
|
version: b84e30acd515aadc4b783ad4ff83aff3299bdfe0
|
||||||
|
- name: golang.org/x/net
|
||||||
|
version: a6577fac2d73be281a500b310739095313165611
|
||||||
|
subpackages:
|
||||||
|
- context
|
||||||
|
- context/ctxhttp
|
||||||
|
- http2
|
||||||
|
- http2/hpack
|
||||||
|
- idna
|
||||||
|
- internal/timeseries
|
||||||
|
- lex/httplex
|
||||||
|
- trace
|
||||||
|
- name: google.golang.org/grpc
|
||||||
|
version: 777daa17ff9b5daef1cfdf915088a2ada3332bf0
|
||||||
|
subpackages:
|
||||||
|
- codes
|
||||||
|
- credentials
|
||||||
|
- grpclog
|
||||||
|
- internal
|
||||||
|
- metadata
|
||||||
|
- naming
|
||||||
|
- peer
|
||||||
|
- transport
|
||||||
|
testImports: []
|
20
examples/go-kit/glide.yaml
Normal file
20
examples/go-kit/glide.yaml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package: github.com/moul/protoc-gen-gotemplate/examples/go-kit
|
||||||
|
import:
|
||||||
|
- package: github.com/go-kit/kit
|
||||||
|
subpackages:
|
||||||
|
- auth/jwt
|
||||||
|
- endpoint
|
||||||
|
- log
|
||||||
|
- transport/grpc
|
||||||
|
- transport/http
|
||||||
|
- package: github.com/golang/protobuf
|
||||||
|
subpackages:
|
||||||
|
- proto
|
||||||
|
version: c9c7427a2a70d2eb3bafa0ab2dc163e45f143317
|
||||||
|
- package: github.com/gorilla/handlers
|
||||||
|
- package: golang.org/x/net
|
||||||
|
subpackages:
|
||||||
|
- context
|
||||||
|
- http2
|
||||||
|
version: a6577fac2d73be281a500b310739095313165611
|
||||||
|
- package: google.golang.org/grpc
|
@ -1,7 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -34,37 +33,36 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
mux := http.NewServeMux()
|
mux := http.NewServeMux()
|
||||||
ctx := context.Background()
|
|
||||||
errc := make(chan error)
|
errc := make(chan error)
|
||||||
s := grpc.NewServer()
|
s := grpc.NewServer()
|
||||||
var logger log.Logger
|
var logger log.Logger
|
||||||
{
|
{
|
||||||
logger = log.NewLogfmtLogger(os.Stdout)
|
logger = log.NewLogfmtLogger(os.Stdout)
|
||||||
logger = log.NewContext(logger).With("ts", log.DefaultTimestampUTC)
|
logger = log.With(logger, "ts", log.DefaultTimestampUTC)
|
||||||
logger = log.NewContext(logger).With("caller", log.DefaultCaller)
|
logger = log.With(logger, "caller", log.DefaultCaller)
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize services
|
// initialize services
|
||||||
{
|
{
|
||||||
svc := session_svc.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(endpoints)
|
||||||
session_pb.RegisterSessionServiceServer(s, srv)
|
session_pb.RegisterSessionServiceServer(s, srv)
|
||||||
session_httptransport.RegisterHandlers(ctx, svc, mux, endpoints)
|
session_httptransport.RegisterHandlers(svc, mux, endpoints)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
svc := sprint_svc.New()
|
svc := sprint_svc.New()
|
||||||
endpoints := sprint_endpoints.MakeEndpoints(svc)
|
endpoints := sprint_endpoints.MakeEndpoints(svc)
|
||||||
srv := sprint_grpctransport.MakeGRPCServer(ctx, endpoints)
|
srv := sprint_grpctransport.MakeGRPCServer(endpoints)
|
||||||
sprint_pb.RegisterSprintServiceServer(s, srv)
|
sprint_pb.RegisterSprintServiceServer(s, srv)
|
||||||
sprint_httptransport.RegisterHandlers(ctx, svc, mux, endpoints)
|
sprint_httptransport.RegisterHandlers(svc, mux, endpoints)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
svc := user_svc.New()
|
svc := user_svc.New()
|
||||||
endpoints := user_endpoints.MakeEndpoints(svc)
|
endpoints := user_endpoints.MakeEndpoints(svc)
|
||||||
srv := user_grpctransport.MakeGRPCServer(ctx, endpoints)
|
srv := user_grpctransport.MakeGRPCServer(endpoints)
|
||||||
user_pb.RegisterUserServiceServer(s, srv)
|
user_pb.RegisterUserServiceServer(s, srv)
|
||||||
user_httptransport.RegisterHandlers(ctx, svc, mux, endpoints)
|
user_httptransport.RegisterHandlers(svc, mux, endpoints)
|
||||||
}
|
}
|
||||||
|
|
||||||
// start servers
|
// start servers
|
||||||
@ -75,13 +73,13 @@ func main() {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
logger := log.NewContext(logger).With("transport", "HTTP")
|
logger := log.With(logger, "transport", "HTTP")
|
||||||
logger.Log("addr", ":8000")
|
logger.Log("addr", ":8000")
|
||||||
errc <- http.ListenAndServe(":8000", handlers.LoggingHandler(os.Stderr, mux))
|
errc <- http.ListenAndServe(":8000", handlers.LoggingHandler(os.Stderr, mux))
|
||||||
}()
|
}()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
logger := log.NewContext(logger).With("transport", "gRPC")
|
logger := log.With(logger, "transport", "gRPC")
|
||||||
ln, err := net.Listen("tcp", ":9000")
|
ln, err := net.Listen("tcp", ":9000")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errc <- err
|
errc <- err
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package session_clientgrpc
|
package session_clientgrpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
context "context"
|
||||||
|
|
||||||
jwt "github.com/go-kit/kit/auth/jwt"
|
jwt "github.com/go-kit/kit/auth/jwt"
|
||||||
"github.com/go-kit/kit/endpoint"
|
"github.com/go-kit/kit/endpoint"
|
||||||
"github.com/go-kit/kit/log"
|
"github.com/go-kit/kit/log"
|
||||||
grpctransport "github.com/go-kit/kit/transport/grpc"
|
grpctransport "github.com/go-kit/kit/transport/grpc"
|
||||||
context "golang.org/x/net/context"
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
|
||||||
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"
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
package session_endpoints
|
package session_endpoints
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
context "context"
|
||||||
"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/gen/pb"
|
pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/session/gen/pb"
|
||||||
context "golang.org/x/net/context"
|
oldcontext "golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var _ = endpoint.Chain
|
||||||
var _ = fmt.Errorf
|
var _ = fmt.Errorf
|
||||||
|
var _ = context.Background
|
||||||
|
|
||||||
type StreamEndpoint func(server interface{}, req interface{}) (err error)
|
type StreamEndpoint func(server interface{}, req interface{}) (err error)
|
||||||
|
|
||||||
@ -16,7 +19,7 @@ type Endpoints struct {
|
|||||||
LoginEndpoint endpoint.Endpoint
|
LoginEndpoint endpoint.Endpoint
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Endpoints) Login(ctx context.Context, in *pb.LoginRequest) (*pb.LoginResponse, error) {
|
func (e *Endpoints) Login(ctx oldcontext.Context, in *pb.LoginRequest) (*pb.LoginResponse, error) {
|
||||||
out, err := e.LoginEndpoint(ctx, in)
|
out, err := e.LoginEndpoint(ctx, in)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &pb.LoginResponse{ErrMsg: err.Error()}, err
|
return &pb.LoginResponse{ErrMsg: err.Error()}, err
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Code generated by protoc-gen-gogo.
|
// Code generated by protoc-gen-go.
|
||||||
// source: services/session/session.proto
|
// source: services/session/session.proto
|
||||||
// DO NOT EDIT!
|
// DO NOT EDIT!
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ It has these top-level messages:
|
|||||||
*/
|
*/
|
||||||
package session
|
package session
|
||||||
|
|
||||||
import proto "github.com/gogo/protobuf/proto"
|
import proto "github.com/golang/protobuf/proto"
|
||||||
import fmt "fmt"
|
import fmt "fmt"
|
||||||
import math "math"
|
import math "math"
|
||||||
|
|
||||||
@ -32,17 +32,17 @@ var _ = math.Inf
|
|||||||
// is compatible with the proto package it is being compiled against.
|
// is compatible with the proto package it is being compiled against.
|
||||||
// A compilation error at this line likely means your copy of the
|
// A compilation error at this line likely means your copy of the
|
||||||
// proto package needs to be updated.
|
// proto package needs to be updated.
|
||||||
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
|
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
|
||||||
|
|
||||||
type LoginRequest struct {
|
type LoginRequest struct {
|
||||||
Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"`
|
Username string `protobuf:"bytes,1,opt,name=username" json:"username,omitempty"`
|
||||||
Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
|
Password string `protobuf:"bytes,2,opt,name=password" json:"password,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *LoginRequest) Reset() { *m = LoginRequest{} }
|
func (m *LoginRequest) Reset() { *m = LoginRequest{} }
|
||||||
func (m *LoginRequest) String() string { return proto.CompactTextString(m) }
|
func (m *LoginRequest) String() string { return proto.CompactTextString(m) }
|
||||||
func (*LoginRequest) ProtoMessage() {}
|
func (*LoginRequest) ProtoMessage() {}
|
||||||
func (*LoginRequest) Descriptor() ([]byte, []int) { return fileDescriptorSession, []int{0} }
|
func (*LoginRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
|
||||||
|
|
||||||
func (m *LoginRequest) GetUsername() string {
|
func (m *LoginRequest) GetUsername() string {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
@ -59,14 +59,14 @@ func (m *LoginRequest) GetPassword() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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" 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" json:"err_msg,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *LoginResponse) Reset() { *m = LoginResponse{} }
|
func (m *LoginResponse) Reset() { *m = LoginResponse{} }
|
||||||
func (m *LoginResponse) String() string { return proto.CompactTextString(m) }
|
func (m *LoginResponse) String() string { return proto.CompactTextString(m) }
|
||||||
func (*LoginResponse) ProtoMessage() {}
|
func (*LoginResponse) ProtoMessage() {}
|
||||||
func (*LoginResponse) Descriptor() ([]byte, []int) { return fileDescriptorSession, []int{1} }
|
func (*LoginResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
|
||||||
|
|
||||||
func (m *LoginResponse) GetToken() string {
|
func (m *LoginResponse) GetToken() string {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
@ -159,11 +159,11 @@ var _SessionService_serviceDesc = grpc.ServiceDesc{
|
|||||||
Metadata: "services/session/session.proto",
|
Metadata: "services/session/session.proto",
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { proto.RegisterFile("services/session/session.proto", fileDescriptorSession) }
|
func init() { proto.RegisterFile("services/session/session.proto", fileDescriptor0) }
|
||||||
|
|
||||||
var fileDescriptorSession = []byte{
|
var fileDescriptor0 = []byte{
|
||||||
// 188 bytes of a gzipped FileDescriptorProto
|
// 188 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0x92, 0x2b, 0x4e, 0x2d, 0x2a,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2b, 0x4e, 0x2d, 0x2a,
|
||||||
0xcb, 0x4c, 0x4e, 0x2d, 0xd6, 0x2f, 0x4e, 0x2d, 0x2e, 0xce, 0xcc, 0xcf, 0x83, 0xd1, 0x7a, 0x05,
|
0xcb, 0x4c, 0x4e, 0x2d, 0xd6, 0x2f, 0x4e, 0x2d, 0x2e, 0xce, 0xcc, 0xcf, 0x83, 0xd1, 0x7a, 0x05,
|
||||||
0x45, 0xf9, 0x25, 0xf9, 0x42, 0xec, 0x50, 0xae, 0x92, 0x1b, 0x17, 0x8f, 0x4f, 0x7e, 0x7a, 0x66,
|
0x45, 0xf9, 0x25, 0xf9, 0x42, 0xec, 0x50, 0xae, 0x92, 0x1b, 0x17, 0x8f, 0x4f, 0x7e, 0x7a, 0x66,
|
||||||
0x5e, 0x50, 0x6a, 0x61, 0x69, 0x6a, 0x71, 0x89, 0x90, 0x14, 0x17, 0x47, 0x69, 0x71, 0x6a, 0x51,
|
0x5e, 0x50, 0x6a, 0x61, 0x69, 0x6a, 0x71, 0x89, 0x90, 0x14, 0x17, 0x47, 0x69, 0x71, 0x6a, 0x51,
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
package session_grpctransport
|
package session_grpctransport
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
context "context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
grpctransport "github.com/go-kit/kit/transport/grpc"
|
grpctransport "github.com/go-kit/kit/transport/grpc"
|
||||||
context "golang.org/x/net/context"
|
oldcontext "golang.org/x/net/context"
|
||||||
|
|
||||||
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"
|
pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/session/gen/pb"
|
||||||
@ -13,12 +14,12 @@ import (
|
|||||||
// avoid import errors
|
// avoid import errors
|
||||||
var _ = fmt.Errorf
|
var _ = fmt.Errorf
|
||||||
|
|
||||||
func MakeGRPCServer(ctx context.Context, endpoints endpoints.Endpoints) pb.SessionServiceServer {
|
func MakeGRPCServer(endpoints endpoints.Endpoints) pb.SessionServiceServer {
|
||||||
options := []grpctransport.ServerOption{}
|
var options []grpctransport.ServerOption
|
||||||
|
_ = options
|
||||||
return &grpcServer{
|
return &grpcServer{
|
||||||
|
|
||||||
login: grpctransport.NewServer(
|
login: grpctransport.NewServer(
|
||||||
ctx,
|
|
||||||
endpoints.LoginEndpoint,
|
endpoints.LoginEndpoint,
|
||||||
decodeRequest,
|
decodeRequest,
|
||||||
encodeLoginResponse,
|
encodeLoginResponse,
|
||||||
@ -31,7 +32,7 @@ type grpcServer struct {
|
|||||||
login grpctransport.Handler
|
login grpctransport.Handler
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *grpcServer) Login(ctx context.Context, req *pb.LoginRequest) (*pb.LoginResponse, error) {
|
func (s *grpcServer) Login(ctx oldcontext.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
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package session_httptransport
|
package session_httptransport
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
context "golang.org/x/net/context"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
@ -12,9 +12,12 @@ import (
|
|||||||
pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/session/gen/pb"
|
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 {
|
var _ = log.Printf
|
||||||
|
var _ = gokit_endpoint.Chain
|
||||||
|
var _ = httptransport.NewClient
|
||||||
|
|
||||||
|
func MakeLoginHandler(svc pb.SessionServiceServer, endpoint gokit_endpoint.Endpoint) *httptransport.Server {
|
||||||
return httptransport.NewServer(
|
return httptransport.NewServer(
|
||||||
ctx,
|
|
||||||
endpoint,
|
endpoint,
|
||||||
decodeLoginRequest,
|
decodeLoginRequest,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
@ -34,10 +37,10 @@ func encodeResponse(ctx context.Context, w http.ResponseWriter, response interfa
|
|||||||
return json.NewEncoder(w).Encode(response)
|
return json.NewEncoder(w).Encode(response)
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegisterHandlers(ctx context.Context, svc pb.SessionServiceServer, mux *http.ServeMux, endpoints endpoints.Endpoints) error {
|
func RegisterHandlers(svc pb.SessionServiceServer, mux *http.ServeMux, endpoints endpoints.Endpoints) error {
|
||||||
|
|
||||||
log.Println("new HTTP endpoint: \"/Login\" (service=Session)")
|
log.Println("new HTTP endpoint: \"/Login\" (service=Session)")
|
||||||
mux.Handle("/Login", MakeLoginHandler(ctx, svc, endpoints.LoginEndpoint))
|
mux.Handle("/Login", MakeLoginHandler(svc, endpoints.LoginEndpoint))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package sprint_clientgrpc
|
package sprint_clientgrpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
context "context"
|
||||||
|
|
||||||
jwt "github.com/go-kit/kit/auth/jwt"
|
jwt "github.com/go-kit/kit/auth/jwt"
|
||||||
"github.com/go-kit/kit/endpoint"
|
"github.com/go-kit/kit/endpoint"
|
||||||
"github.com/go-kit/kit/log"
|
"github.com/go-kit/kit/log"
|
||||||
grpctransport "github.com/go-kit/kit/transport/grpc"
|
grpctransport "github.com/go-kit/kit/transport/grpc"
|
||||||
context "golang.org/x/net/context"
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
|
||||||
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"
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
package sprint_endpoints
|
package sprint_endpoints
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
context "context"
|
||||||
"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/gen/pb"
|
pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/sprint/gen/pb"
|
||||||
context "golang.org/x/net/context"
|
oldcontext "golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var _ = endpoint.Chain
|
||||||
var _ = fmt.Errorf
|
var _ = fmt.Errorf
|
||||||
|
var _ = context.Background
|
||||||
|
|
||||||
type StreamEndpoint func(server interface{}, req interface{}) (err error)
|
type StreamEndpoint func(server interface{}, req interface{}) (err error)
|
||||||
|
|
||||||
@ -20,7 +23,7 @@ type Endpoints struct {
|
|||||||
GetSprintEndpoint endpoint.Endpoint
|
GetSprintEndpoint endpoint.Endpoint
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Endpoints) AddSprint(ctx context.Context, in *pb.AddSprintRequest) (*pb.AddSprintResponse, error) {
|
func (e *Endpoints) AddSprint(ctx oldcontext.Context, in *pb.AddSprintRequest) (*pb.AddSprintResponse, error) {
|
||||||
out, err := e.AddSprintEndpoint(ctx, in)
|
out, err := e.AddSprintEndpoint(ctx, in)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &pb.AddSprintResponse{ErrMsg: err.Error()}, err
|
return &pb.AddSprintResponse{ErrMsg: err.Error()}, err
|
||||||
@ -28,7 +31,7 @@ func (e *Endpoints) AddSprint(ctx context.Context, in *pb.AddSprintRequest) (*pb
|
|||||||
return out.(*pb.AddSprintResponse), err
|
return out.(*pb.AddSprintResponse), err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Endpoints) CloseSprint(ctx context.Context, in *pb.CloseSprintRequest) (*pb.CloseSprintResponse, error) {
|
func (e *Endpoints) CloseSprint(ctx oldcontext.Context, in *pb.CloseSprintRequest) (*pb.CloseSprintResponse, error) {
|
||||||
out, err := e.CloseSprintEndpoint(ctx, in)
|
out, err := e.CloseSprintEndpoint(ctx, in)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &pb.CloseSprintResponse{ErrMsg: err.Error()}, err
|
return &pb.CloseSprintResponse{ErrMsg: err.Error()}, err
|
||||||
@ -36,7 +39,7 @@ func (e *Endpoints) CloseSprint(ctx context.Context, in *pb.CloseSprintRequest)
|
|||||||
return out.(*pb.CloseSprintResponse), err
|
return out.(*pb.CloseSprintResponse), err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Endpoints) GetSprint(ctx context.Context, in *pb.GetSprintRequest) (*pb.GetSprintResponse, error) {
|
func (e *Endpoints) GetSprint(ctx oldcontext.Context, in *pb.GetSprintRequest) (*pb.GetSprintResponse, error) {
|
||||||
out, err := e.GetSprintEndpoint(ctx, in)
|
out, err := e.GetSprintEndpoint(ctx, in)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &pb.GetSprintResponse{ErrMsg: err.Error()}, err
|
return &pb.GetSprintResponse{ErrMsg: err.Error()}, err
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Code generated by protoc-gen-gogo.
|
// Code generated by protoc-gen-go.
|
||||||
// source: services/sprint/sprint.proto
|
// source: services/sprint/sprint.proto
|
||||||
// DO NOT EDIT!
|
// DO NOT EDIT!
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ It has these top-level messages:
|
|||||||
*/
|
*/
|
||||||
package sprint
|
package sprint
|
||||||
|
|
||||||
import proto "github.com/gogo/protobuf/proto"
|
import proto "github.com/golang/protobuf/proto"
|
||||||
import fmt "fmt"
|
import fmt "fmt"
|
||||||
import math "math"
|
import math "math"
|
||||||
|
|
||||||
@ -37,16 +37,16 @@ var _ = math.Inf
|
|||||||
// is compatible with the proto package it is being compiled against.
|
// is compatible with the proto package it is being compiled against.
|
||||||
// A compilation error at this line likely means your copy of the
|
// A compilation error at this line likely means your copy of the
|
||||||
// proto package needs to be updated.
|
// proto package needs to be updated.
|
||||||
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
|
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
|
||||||
|
|
||||||
type AddSprintRequest struct {
|
type AddSprintRequest struct {
|
||||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *AddSprintRequest) Reset() { *m = AddSprintRequest{} }
|
func (m *AddSprintRequest) Reset() { *m = AddSprintRequest{} }
|
||||||
func (m *AddSprintRequest) String() string { return proto.CompactTextString(m) }
|
func (m *AddSprintRequest) String() string { return proto.CompactTextString(m) }
|
||||||
func (*AddSprintRequest) ProtoMessage() {}
|
func (*AddSprintRequest) ProtoMessage() {}
|
||||||
func (*AddSprintRequest) Descriptor() ([]byte, []int) { return fileDescriptorSprint, []int{0} }
|
func (*AddSprintRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
|
||||||
|
|
||||||
func (m *AddSprintRequest) GetName() string {
|
func (m *AddSprintRequest) GetName() string {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
@ -57,13 +57,13 @@ func (m *AddSprintRequest) GetName() string {
|
|||||||
|
|
||||||
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" json:"err_msg,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *AddSprintResponse) Reset() { *m = AddSprintResponse{} }
|
func (m *AddSprintResponse) Reset() { *m = AddSprintResponse{} }
|
||||||
func (m *AddSprintResponse) String() string { return proto.CompactTextString(m) }
|
func (m *AddSprintResponse) String() string { return proto.CompactTextString(m) }
|
||||||
func (*AddSprintResponse) ProtoMessage() {}
|
func (*AddSprintResponse) ProtoMessage() {}
|
||||||
func (*AddSprintResponse) Descriptor() ([]byte, []int) { return fileDescriptorSprint, []int{1} }
|
func (*AddSprintResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
|
||||||
|
|
||||||
func (m *AddSprintResponse) GetSprint() *Sprint {
|
func (m *AddSprintResponse) GetSprint() *Sprint {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
@ -80,13 +80,13 @@ func (m *AddSprintResponse) GetErrMsg() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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" json:"id,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *CloseSprintRequest) Reset() { *m = CloseSprintRequest{} }
|
func (m *CloseSprintRequest) Reset() { *m = CloseSprintRequest{} }
|
||||||
func (m *CloseSprintRequest) String() string { return proto.CompactTextString(m) }
|
func (m *CloseSprintRequest) String() string { return proto.CompactTextString(m) }
|
||||||
func (*CloseSprintRequest) ProtoMessage() {}
|
func (*CloseSprintRequest) ProtoMessage() {}
|
||||||
func (*CloseSprintRequest) Descriptor() ([]byte, []int) { return fileDescriptorSprint, []int{2} }
|
func (*CloseSprintRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
|
||||||
|
|
||||||
func (m *CloseSprintRequest) GetId() string {
|
func (m *CloseSprintRequest) GetId() string {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
@ -96,13 +96,13 @@ func (m *CloseSprintRequest) GetId() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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" json:"err_msg,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *CloseSprintResponse) Reset() { *m = CloseSprintResponse{} }
|
func (m *CloseSprintResponse) Reset() { *m = CloseSprintResponse{} }
|
||||||
func (m *CloseSprintResponse) String() string { return proto.CompactTextString(m) }
|
func (m *CloseSprintResponse) String() string { return proto.CompactTextString(m) }
|
||||||
func (*CloseSprintResponse) ProtoMessage() {}
|
func (*CloseSprintResponse) ProtoMessage() {}
|
||||||
func (*CloseSprintResponse) Descriptor() ([]byte, []int) { return fileDescriptorSprint, []int{3} }
|
func (*CloseSprintResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }
|
||||||
|
|
||||||
func (m *CloseSprintResponse) GetErrMsg() string {
|
func (m *CloseSprintResponse) GetErrMsg() string {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
@ -112,13 +112,13 @@ func (m *CloseSprintResponse) GetErrMsg() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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" json:"id,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *GetSprintRequest) Reset() { *m = GetSprintRequest{} }
|
func (m *GetSprintRequest) Reset() { *m = GetSprintRequest{} }
|
||||||
func (m *GetSprintRequest) String() string { return proto.CompactTextString(m) }
|
func (m *GetSprintRequest) String() string { return proto.CompactTextString(m) }
|
||||||
func (*GetSprintRequest) ProtoMessage() {}
|
func (*GetSprintRequest) ProtoMessage() {}
|
||||||
func (*GetSprintRequest) Descriptor() ([]byte, []int) { return fileDescriptorSprint, []int{4} }
|
func (*GetSprintRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} }
|
||||||
|
|
||||||
func (m *GetSprintRequest) GetId() string {
|
func (m *GetSprintRequest) GetId() string {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
@ -129,13 +129,13 @@ func (m *GetSprintRequest) GetId() string {
|
|||||||
|
|
||||||
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" json:"err_msg,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *GetSprintResponse) Reset() { *m = GetSprintResponse{} }
|
func (m *GetSprintResponse) Reset() { *m = GetSprintResponse{} }
|
||||||
func (m *GetSprintResponse) String() string { return proto.CompactTextString(m) }
|
func (m *GetSprintResponse) String() string { return proto.CompactTextString(m) }
|
||||||
func (*GetSprintResponse) ProtoMessage() {}
|
func (*GetSprintResponse) ProtoMessage() {}
|
||||||
func (*GetSprintResponse) Descriptor() ([]byte, []int) { return fileDescriptorSprint, []int{5} }
|
func (*GetSprintResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} }
|
||||||
|
|
||||||
func (m *GetSprintResponse) GetSprint() *Sprint {
|
func (m *GetSprintResponse) GetSprint() *Sprint {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
@ -152,15 +152,15 @@ func (m *GetSprintResponse) GetErrMsg() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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" 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" json:"created_at,omitempty"`
|
||||||
Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"`
|
Name string `protobuf:"bytes,3,opt,name=name" json:"name,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Sprint) Reset() { *m = Sprint{} }
|
func (m *Sprint) Reset() { *m = Sprint{} }
|
||||||
func (m *Sprint) String() string { return proto.CompactTextString(m) }
|
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 fileDescriptor0, []int{6} }
|
||||||
|
|
||||||
func (m *Sprint) GetId() string {
|
func (m *Sprint) GetId() string {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
@ -331,11 +331,11 @@ var _SprintService_serviceDesc = grpc.ServiceDesc{
|
|||||||
Metadata: "services/sprint/sprint.proto",
|
Metadata: "services/sprint/sprint.proto",
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { proto.RegisterFile("services/sprint/sprint.proto", fileDescriptorSprint) }
|
func init() { proto.RegisterFile("services/sprint/sprint.proto", fileDescriptor0) }
|
||||||
|
|
||||||
var fileDescriptorSprint = []byte{
|
var fileDescriptor0 = []byte{
|
||||||
// 290 bytes of a gzipped FileDescriptorProto
|
// 290 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xac, 0x52, 0x4d, 0x4b, 0xc3, 0x40,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x52, 0x4d, 0x4b, 0xc3, 0x40,
|
||||||
0x10, 0x6d, 0xaa, 0x44, 0x32, 0xa5, 0xa5, 0x1d, 0x0f, 0xc6, 0xa8, 0x20, 0x8b, 0x14, 0x4f, 0x11,
|
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,
|
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,
|
0xac, 0xfe, 0x5f, 0xff, 0x89, 0xb0, 0xbb, 0xcd, 0x57, 0x8b, 0x27, 0x4f, 0xc9, 0xec, 0xbc, 0x7d,
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
package sprint_grpctransport
|
package sprint_grpctransport
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
context "context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
grpctransport "github.com/go-kit/kit/transport/grpc"
|
grpctransport "github.com/go-kit/kit/transport/grpc"
|
||||||
context "golang.org/x/net/context"
|
oldcontext "golang.org/x/net/context"
|
||||||
|
|
||||||
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"
|
pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/sprint/gen/pb"
|
||||||
@ -13,12 +14,12 @@ import (
|
|||||||
// avoid import errors
|
// avoid import errors
|
||||||
var _ = fmt.Errorf
|
var _ = fmt.Errorf
|
||||||
|
|
||||||
func MakeGRPCServer(ctx context.Context, endpoints endpoints.Endpoints) pb.SprintServiceServer {
|
func MakeGRPCServer(endpoints endpoints.Endpoints) pb.SprintServiceServer {
|
||||||
options := []grpctransport.ServerOption{}
|
var options []grpctransport.ServerOption
|
||||||
|
_ = options
|
||||||
return &grpcServer{
|
return &grpcServer{
|
||||||
|
|
||||||
addsprint: grpctransport.NewServer(
|
addsprint: grpctransport.NewServer(
|
||||||
ctx,
|
|
||||||
endpoints.AddSprintEndpoint,
|
endpoints.AddSprintEndpoint,
|
||||||
decodeRequest,
|
decodeRequest,
|
||||||
encodeAddSprintResponse,
|
encodeAddSprintResponse,
|
||||||
@ -26,7 +27,6 @@ func MakeGRPCServer(ctx context.Context, endpoints endpoints.Endpoints) pb.Sprin
|
|||||||
),
|
),
|
||||||
|
|
||||||
closesprint: grpctransport.NewServer(
|
closesprint: grpctransport.NewServer(
|
||||||
ctx,
|
|
||||||
endpoints.CloseSprintEndpoint,
|
endpoints.CloseSprintEndpoint,
|
||||||
decodeRequest,
|
decodeRequest,
|
||||||
encodeCloseSprintResponse,
|
encodeCloseSprintResponse,
|
||||||
@ -34,7 +34,6 @@ func MakeGRPCServer(ctx context.Context, endpoints endpoints.Endpoints) pb.Sprin
|
|||||||
),
|
),
|
||||||
|
|
||||||
getsprint: grpctransport.NewServer(
|
getsprint: grpctransport.NewServer(
|
||||||
ctx,
|
|
||||||
endpoints.GetSprintEndpoint,
|
endpoints.GetSprintEndpoint,
|
||||||
decodeRequest,
|
decodeRequest,
|
||||||
encodeGetSprintResponse,
|
encodeGetSprintResponse,
|
||||||
@ -51,7 +50,7 @@ type grpcServer struct {
|
|||||||
getsprint grpctransport.Handler
|
getsprint grpctransport.Handler
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *grpcServer) AddSprint(ctx context.Context, req *pb.AddSprintRequest) (*pb.AddSprintResponse, error) {
|
func (s *grpcServer) AddSprint(ctx oldcontext.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
|
||||||
@ -64,7 +63,7 @@ func encodeAddSprintResponse(ctx context.Context, response interface{}) (interfa
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *grpcServer) CloseSprint(ctx context.Context, req *pb.CloseSprintRequest) (*pb.CloseSprintResponse, error) {
|
func (s *grpcServer) CloseSprint(ctx oldcontext.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
|
||||||
@ -77,7 +76,7 @@ func encodeCloseSprintResponse(ctx context.Context, response interface{}) (inter
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *grpcServer) GetSprint(ctx context.Context, req *pb.GetSprintRequest) (*pb.GetSprintResponse, error) {
|
func (s *grpcServer) GetSprint(ctx oldcontext.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
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package sprint_httptransport
|
package sprint_httptransport
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
context "golang.org/x/net/context"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
@ -12,9 +12,12 @@ import (
|
|||||||
pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/sprint/gen/pb"
|
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 {
|
var _ = log.Printf
|
||||||
|
var _ = gokit_endpoint.Chain
|
||||||
|
var _ = httptransport.NewClient
|
||||||
|
|
||||||
|
func MakeAddSprintHandler(svc pb.SprintServiceServer, endpoint gokit_endpoint.Endpoint) *httptransport.Server {
|
||||||
return httptransport.NewServer(
|
return httptransport.NewServer(
|
||||||
ctx,
|
|
||||||
endpoint,
|
endpoint,
|
||||||
decodeAddSprintRequest,
|
decodeAddSprintRequest,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
@ -30,9 +33,8 @@ func decodeAddSprintRequest(ctx context.Context, r *http.Request) (interface{},
|
|||||||
return &req, nil
|
return &req, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func MakeCloseSprintHandler(ctx context.Context, svc pb.SprintServiceServer, endpoint gokit_endpoint.Endpoint) *httptransport.Server {
|
func MakeCloseSprintHandler(svc pb.SprintServiceServer, endpoint gokit_endpoint.Endpoint) *httptransport.Server {
|
||||||
return httptransport.NewServer(
|
return httptransport.NewServer(
|
||||||
ctx,
|
|
||||||
endpoint,
|
endpoint,
|
||||||
decodeCloseSprintRequest,
|
decodeCloseSprintRequest,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
@ -48,9 +50,8 @@ func decodeCloseSprintRequest(ctx context.Context, r *http.Request) (interface{}
|
|||||||
return &req, nil
|
return &req, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func MakeGetSprintHandler(ctx context.Context, svc pb.SprintServiceServer, endpoint gokit_endpoint.Endpoint) *httptransport.Server {
|
func MakeGetSprintHandler(svc pb.SprintServiceServer, endpoint gokit_endpoint.Endpoint) *httptransport.Server {
|
||||||
return httptransport.NewServer(
|
return httptransport.NewServer(
|
||||||
ctx,
|
|
||||||
endpoint,
|
endpoint,
|
||||||
decodeGetSprintRequest,
|
decodeGetSprintRequest,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
@ -70,16 +71,16 @@ func encodeResponse(ctx context.Context, w http.ResponseWriter, response interfa
|
|||||||
return json.NewEncoder(w).Encode(response)
|
return json.NewEncoder(w).Encode(response)
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegisterHandlers(ctx context.Context, svc pb.SprintServiceServer, mux *http.ServeMux, endpoints endpoints.Endpoints) error {
|
func RegisterHandlers(svc pb.SprintServiceServer, mux *http.ServeMux, endpoints endpoints.Endpoints) error {
|
||||||
|
|
||||||
log.Println("new HTTP endpoint: \"/AddSprint\" (service=Sprint)")
|
log.Println("new HTTP endpoint: \"/AddSprint\" (service=Sprint)")
|
||||||
mux.Handle("/AddSprint", MakeAddSprintHandler(ctx, svc, endpoints.AddSprintEndpoint))
|
mux.Handle("/AddSprint", MakeAddSprintHandler(svc, endpoints.AddSprintEndpoint))
|
||||||
|
|
||||||
log.Println("new HTTP endpoint: \"/CloseSprint\" (service=Sprint)")
|
log.Println("new HTTP endpoint: \"/CloseSprint\" (service=Sprint)")
|
||||||
mux.Handle("/CloseSprint", MakeCloseSprintHandler(ctx, svc, endpoints.CloseSprintEndpoint))
|
mux.Handle("/CloseSprint", MakeCloseSprintHandler(svc, endpoints.CloseSprintEndpoint))
|
||||||
|
|
||||||
log.Println("new HTTP endpoint: \"/GetSprint\" (service=Sprint)")
|
log.Println("new HTTP endpoint: \"/GetSprint\" (service=Sprint)")
|
||||||
mux.Handle("/GetSprint", MakeGetSprintHandler(ctx, svc, endpoints.GetSprintEndpoint))
|
mux.Handle("/GetSprint", MakeGetSprintHandler(svc, endpoints.GetSprintEndpoint))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package user_clientgrpc
|
package user_clientgrpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
context "context"
|
||||||
|
|
||||||
jwt "github.com/go-kit/kit/auth/jwt"
|
jwt "github.com/go-kit/kit/auth/jwt"
|
||||||
"github.com/go-kit/kit/endpoint"
|
"github.com/go-kit/kit/endpoint"
|
||||||
"github.com/go-kit/kit/log"
|
"github.com/go-kit/kit/log"
|
||||||
grpctransport "github.com/go-kit/kit/transport/grpc"
|
grpctransport "github.com/go-kit/kit/transport/grpc"
|
||||||
context "golang.org/x/net/context"
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
|
||||||
endpoints "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/user/gen/endpoints"
|
endpoints "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/user/gen/endpoints"
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
package user_endpoints
|
package user_endpoints
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
context "context"
|
||||||
"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/user/gen/pb"
|
pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/user/gen/pb"
|
||||||
context "golang.org/x/net/context"
|
oldcontext "golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var _ = endpoint.Chain
|
||||||
var _ = fmt.Errorf
|
var _ = fmt.Errorf
|
||||||
|
var _ = context.Background
|
||||||
|
|
||||||
type StreamEndpoint func(server interface{}, req interface{}) (err error)
|
type StreamEndpoint func(server interface{}, req interface{}) (err error)
|
||||||
|
|
||||||
@ -18,7 +21,7 @@ type Endpoints struct {
|
|||||||
GetUserEndpoint endpoint.Endpoint
|
GetUserEndpoint endpoint.Endpoint
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Endpoints) CreateUser(ctx context.Context, in *pb.CreateUserRequest) (*pb.CreateUserResponse, error) {
|
func (e *Endpoints) CreateUser(ctx oldcontext.Context, in *pb.CreateUserRequest) (*pb.CreateUserResponse, error) {
|
||||||
out, err := e.CreateUserEndpoint(ctx, in)
|
out, err := e.CreateUserEndpoint(ctx, in)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &pb.CreateUserResponse{ErrMsg: err.Error()}, err
|
return &pb.CreateUserResponse{ErrMsg: err.Error()}, err
|
||||||
@ -26,7 +29,7 @@ func (e *Endpoints) CreateUser(ctx context.Context, in *pb.CreateUserRequest) (*
|
|||||||
return out.(*pb.CreateUserResponse), err
|
return out.(*pb.CreateUserResponse), err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Endpoints) GetUser(ctx context.Context, in *pb.GetUserRequest) (*pb.GetUserResponse, error) {
|
func (e *Endpoints) GetUser(ctx oldcontext.Context, in *pb.GetUserRequest) (*pb.GetUserResponse, error) {
|
||||||
out, err := e.GetUserEndpoint(ctx, in)
|
out, err := e.GetUserEndpoint(ctx, in)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &pb.GetUserResponse{ErrMsg: err.Error()}, err
|
return &pb.GetUserResponse{ErrMsg: err.Error()}, err
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Code generated by protoc-gen-gogo.
|
// Code generated by protoc-gen-go.
|
||||||
// source: services/user/user.proto
|
// source: services/user/user.proto
|
||||||
// DO NOT EDIT!
|
// DO NOT EDIT!
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ It has these top-level messages:
|
|||||||
*/
|
*/
|
||||||
package user
|
package user
|
||||||
|
|
||||||
import proto "github.com/gogo/protobuf/proto"
|
import proto "github.com/golang/protobuf/proto"
|
||||||
import fmt "fmt"
|
import fmt "fmt"
|
||||||
import math "math"
|
import math "math"
|
||||||
|
|
||||||
@ -35,16 +35,16 @@ var _ = math.Inf
|
|||||||
// is compatible with the proto package it is being compiled against.
|
// is compatible with the proto package it is being compiled against.
|
||||||
// A compilation error at this line likely means your copy of the
|
// A compilation error at this line likely means your copy of the
|
||||||
// proto package needs to be updated.
|
// proto package needs to be updated.
|
||||||
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
|
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
|
||||||
|
|
||||||
type CreateUserRequest struct {
|
type CreateUserRequest struct {
|
||||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *CreateUserRequest) Reset() { *m = CreateUserRequest{} }
|
func (m *CreateUserRequest) Reset() { *m = CreateUserRequest{} }
|
||||||
func (m *CreateUserRequest) String() string { return proto.CompactTextString(m) }
|
func (m *CreateUserRequest) String() string { return proto.CompactTextString(m) }
|
||||||
func (*CreateUserRequest) ProtoMessage() {}
|
func (*CreateUserRequest) ProtoMessage() {}
|
||||||
func (*CreateUserRequest) Descriptor() ([]byte, []int) { return fileDescriptorUser, []int{0} }
|
func (*CreateUserRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
|
||||||
|
|
||||||
func (m *CreateUserRequest) GetName() string {
|
func (m *CreateUserRequest) GetName() string {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
@ -55,13 +55,13 @@ func (m *CreateUserRequest) GetName() string {
|
|||||||
|
|
||||||
type CreateUserResponse struct {
|
type CreateUserResponse struct {
|
||||||
User *User `protobuf:"bytes,1,opt,name=user" json:"user,omitempty"`
|
User *User `protobuf:"bytes,1,opt,name=user" json:"user,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" json:"err_msg,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *CreateUserResponse) Reset() { *m = CreateUserResponse{} }
|
func (m *CreateUserResponse) Reset() { *m = CreateUserResponse{} }
|
||||||
func (m *CreateUserResponse) String() string { return proto.CompactTextString(m) }
|
func (m *CreateUserResponse) String() string { return proto.CompactTextString(m) }
|
||||||
func (*CreateUserResponse) ProtoMessage() {}
|
func (*CreateUserResponse) ProtoMessage() {}
|
||||||
func (*CreateUserResponse) Descriptor() ([]byte, []int) { return fileDescriptorUser, []int{1} }
|
func (*CreateUserResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
|
||||||
|
|
||||||
func (m *CreateUserResponse) GetUser() *User {
|
func (m *CreateUserResponse) GetUser() *User {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
@ -78,13 +78,13 @@ func (m *CreateUserResponse) GetErrMsg() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GetUserRequest struct {
|
type GetUserRequest struct {
|
||||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *GetUserRequest) Reset() { *m = GetUserRequest{} }
|
func (m *GetUserRequest) Reset() { *m = GetUserRequest{} }
|
||||||
func (m *GetUserRequest) String() string { return proto.CompactTextString(m) }
|
func (m *GetUserRequest) String() string { return proto.CompactTextString(m) }
|
||||||
func (*GetUserRequest) ProtoMessage() {}
|
func (*GetUserRequest) ProtoMessage() {}
|
||||||
func (*GetUserRequest) Descriptor() ([]byte, []int) { return fileDescriptorUser, []int{2} }
|
func (*GetUserRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
|
||||||
|
|
||||||
func (m *GetUserRequest) GetId() string {
|
func (m *GetUserRequest) GetId() string {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
@ -95,13 +95,13 @@ func (m *GetUserRequest) GetId() string {
|
|||||||
|
|
||||||
type GetUserResponse struct {
|
type GetUserResponse struct {
|
||||||
User *User `protobuf:"bytes,1,opt,name=user" json:"user,omitempty"`
|
User *User `protobuf:"bytes,1,opt,name=user" json:"user,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" json:"err_msg,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *GetUserResponse) Reset() { *m = GetUserResponse{} }
|
func (m *GetUserResponse) Reset() { *m = GetUserResponse{} }
|
||||||
func (m *GetUserResponse) String() string { return proto.CompactTextString(m) }
|
func (m *GetUserResponse) String() string { return proto.CompactTextString(m) }
|
||||||
func (*GetUserResponse) ProtoMessage() {}
|
func (*GetUserResponse) ProtoMessage() {}
|
||||||
func (*GetUserResponse) Descriptor() ([]byte, []int) { return fileDescriptorUser, []int{3} }
|
func (*GetUserResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }
|
||||||
|
|
||||||
func (m *GetUserResponse) GetUser() *User {
|
func (m *GetUserResponse) GetUser() *User {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
@ -118,14 +118,14 @@ func (m *GetUserResponse) GetErrMsg() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"`
|
||||||
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
|
Name string `protobuf:"bytes,2,opt,name=name" json:"name,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *User) Reset() { *m = User{} }
|
func (m *User) Reset() { *m = User{} }
|
||||||
func (m *User) String() string { return proto.CompactTextString(m) }
|
func (m *User) String() string { return proto.CompactTextString(m) }
|
||||||
func (*User) ProtoMessage() {}
|
func (*User) ProtoMessage() {}
|
||||||
func (*User) Descriptor() ([]byte, []int) { return fileDescriptorUser, []int{4} }
|
func (*User) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} }
|
||||||
|
|
||||||
func (m *User) GetId() string {
|
func (m *User) GetId() string {
|
||||||
if m != nil {
|
if m != nil {
|
||||||
@ -254,11 +254,11 @@ var _UserService_serviceDesc = grpc.ServiceDesc{
|
|||||||
Metadata: "services/user/user.proto",
|
Metadata: "services/user/user.proto",
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { proto.RegisterFile("services/user/user.proto", fileDescriptorUser) }
|
func init() { proto.RegisterFile("services/user/user.proto", fileDescriptor0) }
|
||||||
|
|
||||||
var fileDescriptorUser = []byte{
|
var fileDescriptor0 = []byte{
|
||||||
// 236 bytes of a gzipped FileDescriptorProto
|
// 236 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0x92, 0x28, 0x4e, 0x2d, 0x2a,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x28, 0x4e, 0x2d, 0x2a,
|
||||||
0xcb, 0x4c, 0x4e, 0x2d, 0xd6, 0x2f, 0x2d, 0x4e, 0x2d, 0x02, 0x13, 0x7a, 0x05, 0x45, 0xf9, 0x25,
|
0xcb, 0x4c, 0x4e, 0x2d, 0xd6, 0x2f, 0x2d, 0x4e, 0x2d, 0x02, 0x13, 0x7a, 0x05, 0x45, 0xf9, 0x25,
|
||||||
0xf9, 0x42, 0x2c, 0x20, 0xb6, 0x92, 0x3a, 0x97, 0xa0, 0x73, 0x51, 0x6a, 0x62, 0x49, 0x6a, 0x68,
|
0xf9, 0x42, 0x2c, 0x20, 0xb6, 0x92, 0x3a, 0x97, 0xa0, 0x73, 0x51, 0x6a, 0x62, 0x49, 0x6a, 0x68,
|
||||||
0x71, 0x6a, 0x51, 0x50, 0x6a, 0x61, 0x69, 0x6a, 0x71, 0x89, 0x90, 0x10, 0x17, 0x4b, 0x5e, 0x62,
|
0x71, 0x6a, 0x51, 0x50, 0x6a, 0x61, 0x69, 0x6a, 0x71, 0x89, 0x90, 0x10, 0x17, 0x4b, 0x5e, 0x62,
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
package user_grpctransport
|
package user_grpctransport
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
context "context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
grpctransport "github.com/go-kit/kit/transport/grpc"
|
grpctransport "github.com/go-kit/kit/transport/grpc"
|
||||||
context "golang.org/x/net/context"
|
oldcontext "golang.org/x/net/context"
|
||||||
|
|
||||||
endpoints "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/user/gen/endpoints"
|
endpoints "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/user/gen/endpoints"
|
||||||
pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/user/gen/pb"
|
pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/user/gen/pb"
|
||||||
@ -13,12 +14,12 @@ import (
|
|||||||
// avoid import errors
|
// avoid import errors
|
||||||
var _ = fmt.Errorf
|
var _ = fmt.Errorf
|
||||||
|
|
||||||
func MakeGRPCServer(ctx context.Context, endpoints endpoints.Endpoints) pb.UserServiceServer {
|
func MakeGRPCServer(endpoints endpoints.Endpoints) pb.UserServiceServer {
|
||||||
options := []grpctransport.ServerOption{}
|
var options []grpctransport.ServerOption
|
||||||
|
_ = options
|
||||||
return &grpcServer{
|
return &grpcServer{
|
||||||
|
|
||||||
createuser: grpctransport.NewServer(
|
createuser: grpctransport.NewServer(
|
||||||
ctx,
|
|
||||||
endpoints.CreateUserEndpoint,
|
endpoints.CreateUserEndpoint,
|
||||||
decodeRequest,
|
decodeRequest,
|
||||||
encodeCreateUserResponse,
|
encodeCreateUserResponse,
|
||||||
@ -26,7 +27,6 @@ func MakeGRPCServer(ctx context.Context, endpoints endpoints.Endpoints) pb.UserS
|
|||||||
),
|
),
|
||||||
|
|
||||||
getuser: grpctransport.NewServer(
|
getuser: grpctransport.NewServer(
|
||||||
ctx,
|
|
||||||
endpoints.GetUserEndpoint,
|
endpoints.GetUserEndpoint,
|
||||||
decodeRequest,
|
decodeRequest,
|
||||||
encodeGetUserResponse,
|
encodeGetUserResponse,
|
||||||
@ -41,7 +41,7 @@ type grpcServer struct {
|
|||||||
getuser grpctransport.Handler
|
getuser grpctransport.Handler
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *grpcServer) CreateUser(ctx context.Context, req *pb.CreateUserRequest) (*pb.CreateUserResponse, error) {
|
func (s *grpcServer) CreateUser(ctx oldcontext.Context, req *pb.CreateUserRequest) (*pb.CreateUserResponse, error) {
|
||||||
_, rep, err := s.createuser.ServeGRPC(ctx, req)
|
_, rep, err := s.createuser.ServeGRPC(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -54,7 +54,7 @@ func encodeCreateUserResponse(ctx context.Context, response interface{}) (interf
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *grpcServer) GetUser(ctx context.Context, req *pb.GetUserRequest) (*pb.GetUserResponse, error) {
|
func (s *grpcServer) GetUser(ctx oldcontext.Context, req *pb.GetUserRequest) (*pb.GetUserResponse, error) {
|
||||||
_, rep, err := s.getuser.ServeGRPC(ctx, req)
|
_, rep, err := s.getuser.ServeGRPC(ctx, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package user_httptransport
|
package user_httptransport
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
context "golang.org/x/net/context"
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
@ -12,9 +12,12 @@ import (
|
|||||||
pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/user/gen/pb"
|
pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/user/gen/pb"
|
||||||
)
|
)
|
||||||
|
|
||||||
func MakeCreateUserHandler(ctx context.Context, svc pb.UserServiceServer, endpoint gokit_endpoint.Endpoint) *httptransport.Server {
|
var _ = log.Printf
|
||||||
|
var _ = gokit_endpoint.Chain
|
||||||
|
var _ = httptransport.NewClient
|
||||||
|
|
||||||
|
func MakeCreateUserHandler(svc pb.UserServiceServer, endpoint gokit_endpoint.Endpoint) *httptransport.Server {
|
||||||
return httptransport.NewServer(
|
return httptransport.NewServer(
|
||||||
ctx,
|
|
||||||
endpoint,
|
endpoint,
|
||||||
decodeCreateUserRequest,
|
decodeCreateUserRequest,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
@ -30,9 +33,8 @@ func decodeCreateUserRequest(ctx context.Context, r *http.Request) (interface{},
|
|||||||
return &req, nil
|
return &req, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func MakeGetUserHandler(ctx context.Context, svc pb.UserServiceServer, endpoint gokit_endpoint.Endpoint) *httptransport.Server {
|
func MakeGetUserHandler(svc pb.UserServiceServer, endpoint gokit_endpoint.Endpoint) *httptransport.Server {
|
||||||
return httptransport.NewServer(
|
return httptransport.NewServer(
|
||||||
ctx,
|
|
||||||
endpoint,
|
endpoint,
|
||||||
decodeGetUserRequest,
|
decodeGetUserRequest,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
@ -52,13 +54,13 @@ func encodeResponse(ctx context.Context, w http.ResponseWriter, response interfa
|
|||||||
return json.NewEncoder(w).Encode(response)
|
return json.NewEncoder(w).Encode(response)
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegisterHandlers(ctx context.Context, svc pb.UserServiceServer, mux *http.ServeMux, endpoints endpoints.Endpoints) error {
|
func RegisterHandlers(svc pb.UserServiceServer, mux *http.ServeMux, endpoints endpoints.Endpoints) error {
|
||||||
|
|
||||||
log.Println("new HTTP endpoint: \"/CreateUser\" (service=User)")
|
log.Println("new HTTP endpoint: \"/CreateUser\" (service=User)")
|
||||||
mux.Handle("/CreateUser", MakeCreateUserHandler(ctx, svc, endpoints.CreateUserEndpoint))
|
mux.Handle("/CreateUser", MakeCreateUserHandler(svc, endpoints.CreateUserEndpoint))
|
||||||
|
|
||||||
log.Println("new HTTP endpoint: \"/GetUser\" (service=User)")
|
log.Println("new HTTP endpoint: \"/GetUser\" (service=User)")
|
||||||
mux.Handle("/GetUser", MakeGetUserHandler(ctx, svc, endpoints.GetUserEndpoint))
|
mux.Handle("/GetUser", MakeGetUserHandler(svc, endpoints.GetUserEndpoint))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package {{.File.Package}}_clientgrpc
|
package {{.File.Package}}_clientgrpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
context "context"
|
||||||
|
|
||||||
"github.com/go-kit/kit/log"
|
"github.com/go-kit/kit/log"
|
||||||
context "golang.org/x/net/context"
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
grpctransport "github.com/go-kit/kit/transport/grpc"
|
grpctransport "github.com/go-kit/kit/transport/grpc"
|
||||||
"github.com/go-kit/kit/endpoint"
|
"github.com/go-kit/kit/endpoint"
|
||||||
|
@ -3,9 +3,10 @@ package {{.File.Package}}_endpoints
|
|||||||
{{$file := .File}}
|
{{$file := .File}}
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
context "context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
context "golang.org/x/net/context"
|
oldcontext "golang.org/x/net/context"
|
||||||
pb "{{cat .GoPWD "/" .DestinationDir | nospace | clean}}/pb"
|
pb "{{cat .GoPWD "/" .DestinationDir | nospace | clean}}/pb"
|
||||||
"github.com/go-kit/kit/endpoint"
|
"github.com/go-kit/kit/endpoint"
|
||||||
)
|
)
|
||||||
@ -43,7 +44,7 @@ type Endpoints struct {
|
|||||||
return fmt.Errorf("not implemented")
|
return fmt.Errorf("not implemented")
|
||||||
}
|
}
|
||||||
{{else}}
|
{{else}}
|
||||||
func (e *Endpoints){{.Name}}(ctx context.Context, in *pb.{{.InputType | splitArray "." | last}}) (*pb.{{.OutputType | splitArray "." | last}}, error) {
|
func (e *Endpoints){{.Name}}(ctx oldcontext.Context, in *pb.{{.InputType | splitArray "." | last}}) (*pb.{{.OutputType | splitArray "." | last}}, error) {
|
||||||
out, err := e.{{.Name}}Endpoint(ctx, in)
|
out, err := e.{{.Name}}Endpoint(ctx, in)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &pb.{{.OutputType | splitArray "." | last}}{ErrMsg: err.Error()}, err
|
return &pb.{{.OutputType | splitArray "." | last}}{ErrMsg: err.Error()}, err
|
||||||
|
@ -3,9 +3,10 @@ package {{.File.Package}}_grpctransport
|
|||||||
{{$file := .File}}
|
{{$file := .File}}
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
context "context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
context "golang.org/x/net/context"
|
oldcontext "golang.org/x/net/context"
|
||||||
grpctransport "github.com/go-kit/kit/transport/grpc"
|
grpctransport "github.com/go-kit/kit/transport/grpc"
|
||||||
|
|
||||||
pb "{{cat .GoPWD "/" .DestinationDir | nospace | clean}}/pb"
|
pb "{{cat .GoPWD "/" .DestinationDir | nospace | clean}}/pb"
|
||||||
@ -15,7 +16,7 @@ import (
|
|||||||
// avoid import errors
|
// avoid import errors
|
||||||
var _ = fmt.Errorf
|
var _ = fmt.Errorf
|
||||||
|
|
||||||
func MakeGRPCServer(ctx context.Context, endpoints endpoints.Endpoints) pb.{{.File.Package | title}}ServiceServer {
|
func MakeGRPCServer(endpoints endpoints.Endpoints) pb.{{.File.Package | title}}ServiceServer {
|
||||||
var options []grpctransport.ServerOption
|
var options []grpctransport.ServerOption
|
||||||
_ = options
|
_ = options
|
||||||
return &grpcServer{
|
return &grpcServer{
|
||||||
@ -26,7 +27,6 @@ func MakeGRPCServer(ctx context.Context, endpoints endpoints.Endpoints) pb.{{.Fi
|
|||||||
},
|
},
|
||||||
{{else}}
|
{{else}}
|
||||||
{{.Name | lower}}: grpctransport.NewServer(
|
{{.Name | lower}}: grpctransport.NewServer(
|
||||||
ctx,
|
|
||||||
endpoints.{{.Name}}Endpoint,
|
endpoints.{{.Name}}Endpoint,
|
||||||
decodeRequest,
|
decodeRequest,
|
||||||
encode{{.Name}}Response,
|
encode{{.Name}}Response,
|
||||||
@ -57,7 +57,7 @@ type grpcServer struct {
|
|||||||
return s.{{.Name | lower}}.Do(server, req)
|
return s.{{.Name | lower}}.Do(server, req)
|
||||||
}
|
}
|
||||||
{{else}}
|
{{else}}
|
||||||
func (s *grpcServer) {{.Name}}(ctx context.Context, req *pb.{{.InputType | splitArray "." | last}}) (*pb.{{.OutputType | splitArray "." | last}}, error) {
|
func (s *grpcServer) {{.Name}}(ctx oldcontext.Context, req *pb.{{.InputType | splitArray "." | last}}) (*pb.{{.OutputType | splitArray "." | last}}, 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
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
context "golang.org/x/net/context"
|
"context"
|
||||||
|
|
||||||
pb "{{cat .GoPWD "/" .DestinationDir | nospace | clean}}/pb"
|
pb "{{cat .GoPWD "/" .DestinationDir | nospace | clean}}/pb"
|
||||||
gokit_endpoint "github.com/go-kit/kit/endpoint"
|
gokit_endpoint "github.com/go-kit/kit/endpoint"
|
||||||
@ -21,9 +21,8 @@ var _ = httptransport.NewClient
|
|||||||
|
|
||||||
{{range .Service.Method}}
|
{{range .Service.Method}}
|
||||||
{{if and (not .ServerStreaming) (not .ClientStreaming)}}
|
{{if and (not .ServerStreaming) (not .ClientStreaming)}}
|
||||||
func Make{{.Name}}Handler(ctx context.Context, svc pb.{{$file.Package | title}}ServiceServer, endpoint gokit_endpoint.Endpoint) *httptransport.Server {
|
func Make{{.Name}}Handler(svc pb.{{$file.Package | title}}ServiceServer, endpoint gokit_endpoint.Endpoint) *httptransport.Server {
|
||||||
return httptransport.NewServer(
|
return httptransport.NewServer(
|
||||||
ctx,
|
|
||||||
endpoint,
|
endpoint,
|
||||||
decode{{.Name}}Request,
|
decode{{.Name}}Request,
|
||||||
encodeResponse,
|
encodeResponse,
|
||||||
@ -45,11 +44,11 @@ func encodeResponse(ctx context.Context, w http.ResponseWriter, response interfa
|
|||||||
return json.NewEncoder(w).Encode(response)
|
return json.NewEncoder(w).Encode(response)
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegisterHandlers(ctx context.Context, svc pb.{{$file.Package | title}}ServiceServer, mux *http.ServeMux, endpoints endpoints.Endpoints) error {
|
func RegisterHandlers(svc pb.{{$file.Package | title}}ServiceServer, mux *http.ServeMux, endpoints endpoints.Endpoints) error {
|
||||||
{{range .Service.Method}}
|
{{range .Service.Method}}
|
||||||
{{if and (not .ServerStreaming) (not .ClientStreaming)}}
|
{{if and (not .ServerStreaming) (not .ClientStreaming)}}
|
||||||
log.Println("new HTTP endpoint: \"/{{.Name}}\" (service={{$file.Package | title}})")
|
log.Println("new HTTP endpoint: \"/{{.Name}}\" (service={{$file.Package | title}})")
|
||||||
mux.Handle("/{{.Name}}", Make{{.Name}}Handler(ctx, svc, endpoints.{{.Name}}Endpoint))
|
mux.Handle("/{{.Name}}", Make{{.Name}}Handler(svc, endpoints.{{.Name}}Endpoint))
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user