Коммит
bd71b70e9b
|
@ -321,7 +321,12 @@ func EncodeHTTPGenericResponse(_ context.Context, w http.ResponseWriter, respons
|
|||
|
||||
func headersToContext(ctx context.Context, r *http.Request) context.Context {
|
||||
for k, _ := range r.Header {
|
||||
// The key is added both in http format (k) which has had
|
||||
// http.CanonicalHeaderKey called on it in transport as well as the
|
||||
// strings.ToLower which is the grpc metadata format of the key so
|
||||
// that it can be accessed in either format
|
||||
ctx = context.WithValue(ctx, k, r.Header.Get(k))
|
||||
ctx = context.WithValue(ctx, strings.ToLower(k), r.Header.Get(k))
|
||||
}
|
||||
|
||||
return ctx
|
||||
|
@ -361,8 +366,7 @@ func New(instance string, options ...ClientOption) (handler.Service, error) {
|
|||
for _, f := range options {
|
||||
err := f(&cc)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "cannot apply option")
|
||||
}
|
||||
return nil, errors.Wrap(err, "cannot apply option") }
|
||||
}
|
||||
|
||||
clientOptions := []httptransport.ClientOption{
|
||||
|
|
|
@ -62,7 +62,7 @@ func main() {
|
|||
os.Exit(1)
|
||||
}
|
||||
defer conn.Close()
|
||||
service = grpcclient.New(conn)
|
||||
service, err = grpcclient.New(conn)
|
||||
} else {
|
||||
fmt.Fprintf(os.Stderr, "error: no remote address specified\n")
|
||||
os.Exit(1)
|
||||
|
|
|
@ -2,7 +2,10 @@
|
|||
package grpc
|
||||
|
||||
import (
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/go-kit/kit/endpoint"
|
||||
grpctransport "github.com/go-kit/kit/transport/grpc"
|
||||
|
@ -14,11 +17,21 @@ import (
|
|||
)
|
||||
|
||||
// New returns an service backed by a gRPC client connection. It is the
|
||||
// responsibility of the caller to dial, and later close, the connection.
|
||||
func New(conn *grpc.ClientConn) handler.Service {
|
||||
//options := []grpctransport.ClientOptions{
|
||||
//grpctransport.ClientBefore(),
|
||||
//}
|
||||
// responsibility of the caller to dial, and later close, the connection.
|
||||
func New(conn *grpc.ClientConn, options ...ClientOption) (handler.Service, error) {
|
||||
var cc clientConfig
|
||||
|
||||
for _, f := range options {
|
||||
err := f(&cc)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "cannot apply option")
|
||||
}
|
||||
}
|
||||
|
||||
clientOptions := []grpctransport.ClientOption{
|
||||
grpctransport.ClientBefore(
|
||||
contextValuesToGRPCMetadata(cc.headers)),
|
||||
}
|
||||
|
||||
{{- with $tE := .}}
|
||||
{{- range $i := $tE.Service.Methods}}
|
||||
|
@ -31,7 +44,7 @@ func New(conn *grpc.ClientConn) handler.Service {
|
|||
svc.EncodeGRPC{{$i.GetName}}Request,
|
||||
svc.DecodeGRPC{{$i.GetName}}Response,
|
||||
pb.{{GoName $i.ResponseType.GetName}}{},
|
||||
//options...,
|
||||
clientOptions...,
|
||||
).Endpoint()
|
||||
}
|
||||
{{end}}
|
||||
|
@ -41,5 +54,36 @@ func New(conn *grpc.ClientConn) handler.Service {
|
|||
{{range $i := .Service.Methods -}}
|
||||
{{$i.GetName}}Endpoint: {{ToLower $i.GetName}}Endpoint,
|
||||
{{end}}
|
||||
}, nil
|
||||
}
|
||||
|
||||
type clientConfig struct {
|
||||
headers []string
|
||||
}
|
||||
|
||||
// ClientOption is a function that modifies the client config
|
||||
type ClientOption func(*clientConfig) error
|
||||
|
||||
func CtxValuesToSend(keys ...string) ClientOption {
|
||||
return func(o *clientConfig) error {
|
||||
o.headers = keys
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func contextValuesToGRPCMetadata(keys []string) grpctransport.RequestFunc {
|
||||
return func(ctx context.Context, md *metadata.MD) context.Context {
|
||||
var pairs []string
|
||||
for _, k := range keys {
|
||||
if v, ok := ctx.Value(k).(string); ok {
|
||||
pairs = append(pairs, k, v)
|
||||
}
|
||||
}
|
||||
|
||||
if pairs != nil {
|
||||
*md = metadata.Join(*md, metadata.Pairs(pairs...))
|
||||
}
|
||||
|
||||
return ctx
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,10 @@ package svc
|
|||
// It utilizes the transport/grpc.Server.
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc/metadata"
|
||||
|
||||
grpctransport "github.com/go-kit/kit/transport/grpc"
|
||||
|
||||
|
@ -15,9 +18,9 @@ import (
|
|||
|
||||
// MakeGRPCServer makes a set of endpoints available as a gRPC {{GoName .Service.GetName}}Server.
|
||||
func MakeGRPCServer(ctx context.Context, endpoints Endpoints) pb.{{GoName .Service.GetName}}Server {
|
||||
//options := []grpctransport.ServerOption{
|
||||
// grpctransport.ServiceBefore()
|
||||
//}
|
||||
serverOptions := []grpctransport.ServerOption{
|
||||
grpctransport.ServerBefore(metadataToContext),
|
||||
}
|
||||
return &grpcServer{
|
||||
// {{ ToLower .Service.GetName }}
|
||||
{{range $i := .Service.Methods}}
|
||||
|
@ -26,7 +29,7 @@ func MakeGRPCServer(ctx context.Context, endpoints Endpoints) pb.{{GoName .Servi
|
|||
endpoints.{{$i.GetName}}Endpoint,
|
||||
DecodeGRPC{{$i.GetName}}Request,
|
||||
EncodeGRPC{{$i.GetName}}Response,
|
||||
//options...,
|
||||
serverOptions...,
|
||||
),
|
||||
{{- end}}
|
||||
}
|
||||
|
@ -92,3 +95,18 @@ func EncodeGRPC{{$i.GetName}}Request(_ context.Context, request interface{}) (in
|
|||
}
|
||||
{{end}}
|
||||
|
||||
// Helpers
|
||||
|
||||
func metadataToContext(ctx context.Context, md *metadata.MD) context.Context {
|
||||
for k, v := range *md {
|
||||
if v != nil {
|
||||
// The key is added both in metadata format (k) which is all lower
|
||||
// and the http.CanonicalHeaderKey of the key so that it can be
|
||||
// accessed in either format
|
||||
ctx = context.WithValue(ctx, k, v[0])
|
||||
ctx = context.WithValue(ctx, http.CanonicalHeaderKey(k), v[0])
|
||||
}
|
||||
}
|
||||
|
||||
return ctx
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ func (fi bindataFileInfo) Sys() interface{} {
|
|||
return nil
|
||||
}
|
||||
|
||||
var _nameServiceNameClientClient_mainGotemplate = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xac\x56\xdd\x6e\xdb\x38\x13\xbd\x16\x9f\x62\x2a\xa4\x80\x5c\xb8\x74\x3f\xe0\xdb\x1b\x03\xbe\x48\xb3\xe9\x36\xc0\xb6\x30\xe2\x00\xbd\x29\xb0\x60\xc8\x91\xc4\x8d\x44\xaa\x24\xad\x24\x10\xf4\xee\x8b\xa1\x64\xd9\x4e\x9d\x66\xbb\xbb\x05\x1a\x49\xa3\x99\x33\x7f\xe7\x50\x6e\x84\xbc\x13\x05\x42\x2d\xb4\x61\x4c\xd7\x8d\x75\x01\x32\x96\xa4\x68\xa4\x55\xda\x14\x8b\x3f\xbd\x35\x29\x4b\xd2\xbc\x12\x45\xbc\xd6\x81\x2e\xd6\xd3\x5f\x1f\x9c\xb4\xa6\x1d\x6f\xb5\x29\xa2\x35\xe8\x1a\x53\xc6\x92\xb4\xb0\x95\x30\x05\xb7\xae\x58\x3c\x2c\x0c\x86\x85\xb4\x26\xe0\x43\x04\x28\xac\x2d\x2a\xe4\x07\x2e\x85\x6b\xe4\x10\xa6\x43\xb9\xbd\xe5\xd2\xd6\x8b\xe6\xae\x58\xa0\x73\xd6\x79\x7a\xb3\x58\xc0\x4d\xa9\x3d\x6c\xd0\xb5\x5a\x22\x4b\x4a\x61\x54\x85\x0e\xd2\xae\xe3\x57\xb1\xf8\xb5\x08\x25\xbc\xed\x7b\x58\x8c\xef\xfc\xc2\xa3\x6b\xd1\xa5\x2c\x91\x95\x46\x13\x3e\xfe\x9d\x98\xc1\x35\x65\x09\x15\x35\x3c\x9c\x0c\x28\xd0\xa0\x13\x01\xd5\x18\x31\x36\x91\x94\x21\x34\x3f\x13\x46\xfe\x29\x4b\x9a\xdb\xe8\xbe\x7e\x7f\x1c\x90\xb2\x19\x63\xad\x70\xb4\x99\x3f\x60\x05\xe3\xd8\xf9\x5a\x38\x8f\x57\x26\x4c\x56\xda\x00\xdf\x34\x95\x1e\x4d\xb4\x3c\x7e\x61\xeb\x46\xc8\xd1\x32\x0c\x93\x7f\x71\xa2\xc9\x07\x4b\x73\xcb\xaf\xb1\xd0\x3e\xa0\xeb\x3a\x3e\x8e\x96\xff\x86\xe1\xb3\xa8\xb1\xef\x37\x71\x7a\x54\x00\xcb\xb7\x46\x46\xa6\x64\x33\xe8\xc6\x6d\x20\x08\xa5\x64\xa5\xa1\x71\xe8\xb7\x35\x7a\x30\x16\xfc\x00\x02\x4a\x7b\x69\x5b\x74\x8f\xe0\x1f\x7d\xc0\x7a\x0e\xc2\x28\xc0\x87\x06\x65\xf0\xb0\xf5\xe8\x3c\x04\x1b\x91\x1a\x67\x5b\xad\x10\x42\x49\x61\x0e\x65\x20\x60\x87\xde\x83\xcd\x41\x98\x1d\x26\x1f\x18\x30\x64\x6b\x82\xb6\x06\xb4\x07\x87\x79\x85\x32\xa0\x02\x6d\x22\x1c\xc1\x50\x55\xb7\xda\x08\xf7\x18\xd3\x92\x69\x34\xd3\x5a\x46\xe6\xfb\x65\x34\xbe\x0d\x4e\x18\x4f\x33\xe7\x94\x16\x88\xed\x3e\x22\x51\x68\x2b\x9c\xb6\x5b\xbf\x0b\x95\xd6\xf8\xe0\xb6\x32\x58\xe7\xe1\xd6\x86\x72\x6c\x09\x4a\xeb\xc3\x32\x4a\x68\xb7\x0b\xc6\x92\x71\x6f\x91\x12\xe7\x84\x3d\xfc\x5b\xc5\x1c\x7c\x13\x1d\xb3\x94\xde\xc6\xd4\xe9\x1c\x52\xfa\xff\xf1\xe6\x66\x7d\x34\x02\xa5\x7c\x2b\xd3\x19\x4b\x22\x27\x9f\x47\xa2\xb7\x13\xd2\xf2\x97\x77\xff\x7f\x47\x37\xc5\xf5\xfa\x02\x32\x02\x9d\x3d\x83\x5a\x63\x28\xad\x02\x38\x8d\x3a\xbc\x25\xa4\xae\x73\xc2\x14\x08\x67\xda\x28\x7c\x98\xc3\x99\x86\xe5\x0a\x26\xe2\x7c\x8a\x8e\xbe\xef\xbb\x4e\xe7\xa3\x13\x3d\x60\xe5\x91\xae\x37\xf6\x77\x7b\x8f\x0e\xce\xf4\x9e\x63\x5d\x87\x46\x4d\x97\x74\x9e\xfc\xb3\x24\xf3\x09\xe7\x07\x49\xa8\xd7\xd9\xc1\x5a\xba\x8e\x5f\xc4\xb5\x9e\xbb\xc2\xf3\xf3\xaa\xfa\x40\xab\xef\x7b\xf2\x4a\xe2\x08\xa2\xca\x32\x12\xc0\x14\xb4\x23\xf8\x78\x5e\xf0\xe9\x40\x4a\xd0\x0d\x6b\x89\x3a\x8b\x18\x3a\x87\x37\xd3\xee\x5f\xad\x20\x4d\x49\x3c\x3b\x88\x39\x79\xc2\x0a\xf6\x07\x06\xff\x8c\xf7\xd9\x14\x31\x63\x49\x0f\x34\x3b\x20\x9c\x69\xf3\x7b\x1c\x69\x8d\x19\x40\x96\x2b\x88\xbb\xff\x55\x8b\x2a\x9b\x5c\xe7\x83\xf1\x8b\x0e\xe5\x95\xf1\x28\xb7\x0e\xb3\xd9\x81\xf1\x46\xd7\x68\xb7\x21\xa3\x43\x9b\x6f\x50\x5a\xa3\x66\x44\x07\x9d\x47\xd0\x57\x2b\x30\xba\x8a\x99\x92\xbc\x0e\xfc\x43\xe3\xb4\x09\x79\x66\x3d\xdf\x04\x85\xce\xcd\x21\xbd\xa4\x5e\xe1\xbe\xd4\x15\x69\x57\x54\xda\x14\x11\x9f\x84\x62\x50\x92\x48\x97\xf0\xba\x4d\x63\x99\x84\x9d\x58\xcf\x2f\x1f\x74\xc8\xfe\x47\x4f\x3d\x4b\x12\x85\x39\xba\xe8\xcf\x2f\x2a\x1b\xc7\xbd\x9f\xf2\xd0\xd7\xc1\x74\xc8\x6f\x3f\x18\xaa\xed\xb9\xd2\xe2\x1a\x96\x74\x26\x39\xac\x6d\xc0\x89\xfb\xbe\x41\xa9\x73\x8d\xea\xab\x89\xec\x3f\xac\xa8\x67\x27\xba\x7f\x21\xc3\xeb\xf6\xab\xd9\x37\x78\x8c\xc6\x12\x7f\xaf\x83\x2c\xe1\xcd\xa8\xb1\x8e\x75\x1d\xdc\xeb\x50\xc2\x59\xb8\x8c\xc4\x26\xbe\xed\x39\x4f\xa6\xb3\x70\xf9\x3d\xdd\x69\xdf\xc2\x23\x89\xf0\x14\xc5\xd3\x25\x0d\xb7\xeb\xde\x0e\xe0\x51\x16\x11\xe8\x80\xe1\x84\x45\x37\x07\x81\xf4\x89\xa1\xc0\x48\x6f\x6a\x7b\x24\x6f\xc4\xe2\x9f\x84\xf3\xa5\xd8\xcb\x62\x48\x10\xb5\x44\x0f\x0e\xbf\x6d\xd1\x87\x89\x82\x47\x1f\x59\xde\x75\x87\xf5\x65\x5d\xf7\x53\x85\x91\x68\xf9\x85\xa8\x2a\xb2\x4f\x0a\x8e\x0c\x3a\x41\xcf\x17\xf8\x29\x45\x15\x99\xf9\xa3\x02\x9f\xee\xf1\x09\x53\xe3\x2e\x93\xa4\x9d\x9a\xdd\x7d\x94\x9e\xb4\x39\xfe\xcc\xe1\xef\x85\xbc\x2b\x9c\xdd\x1a\x45\x92\x1b\x27\xf5\x2f\xcb\x3f\x9d\xf2\xe5\xc2\xc7\x04\x6b\xc2\xaf\x4c\x96\x0e\x93\x87\xeb\xa1\x28\x54\x91\x32\xcb\xa8\x85\x23\xc7\xff\x6e\x65\x47\xe9\x87\x9f\x15\x70\x8d\xbe\xb1\x46\x3d\x9f\xbe\x9d\xb1\x03\xbe\x1d\x30\x4f\x61\x2e\xb6\x55\x58\xbe\x2c\x4d\x6d\x5a\x51\x69\x05\xa3\xf8\x5e\x7f\x8b\x83\x1a\x9e\xbe\x17\x6b\xcf\xd8\x5f\x01\x00\x00\xff\xff\x5e\x2d\xc2\x5e\x15\x0b\x00\x00")
|
||||
var _nameServiceNameClientClient_mainGotemplate = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xac\x56\xd1\x6f\xdb\xb6\x13\x7e\x16\xff\x8a\xab\x90\x02\x72\xe1\xd2\xfd\x01\xbf\xbd\x18\xf0\x43\x9b\xa5\x6b\x80\xb5\x30\xe2\x00\x7d\x29\x30\x30\xe4\x49\xe2\x22\x91\x2a\x49\x2b\x09\x04\xfd\xef\xc3\x51\xb2\x6c\x27\x4e\xb3\x6e\x2b\xd0\x48\x3c\xde\x7d\x77\xbc\xfb\x3e\xca\x8d\x90\xb7\xa2\x40\xa8\x85\x36\x8c\xe9\xba\xb1\x2e\x40\xc6\x92\x14\x8d\xb4\x4a\x9b\x62\xf1\xa7\xb7\x26\x65\x49\x9a\x57\xa2\x88\xcf\x3a\xd0\xc3\x7a\xfa\xeb\x83\x93\xd6\xb4\xe3\xab\x36\x45\xb4\x06\x5d\x63\xca\x58\x92\x16\xb6\x12\xa6\xe0\xd6\x15\x8b\xfb\x85\xc1\xb0\x90\xd6\x04\xbc\x8f\x00\x85\xb5\x45\x85\xfc\xc0\xa5\x70\x8d\x1c\xc2\x74\x28\xb7\x37\x5c\xda\x7a\xd1\xdc\x16\x0b\x74\xce\x3a\x4f\x3b\x8b\x05\x5c\x97\xda\xc3\x06\x5d\xab\x25\xb2\xa4\x14\x46\x55\xe8\x20\xed\x3a\x7e\x19\x8b\x5f\x8b\x50\xc2\xdb\xbe\x87\xc5\xb8\xe7\x17\x1e\x5d\x8b\x2e\x65\x89\xac\x34\x9a\xf0\xe9\xef\xc4\x0c\xae\x29\x4b\xa8\xa8\x61\x71\x32\xa0\x40\x83\x4e\x04\x54\x63\xc4\x78\x88\xa4\x0c\xa1\xf9\x99\x30\xf2\x4f\x59\xd2\xdc\x44\xf7\xf5\x87\xe3\x80\x94\xcd\x18\x6b\x85\xa3\xc9\xfc\x01\x2b\x18\xdb\xce\xd7\xc2\x79\xbc\x34\x61\xb2\xd2\x04\xf8\xa6\xa9\xf4\x68\xa2\xe1\xf1\x73\x5b\x37\x42\x8e\x96\xa1\x99\xfc\xab\x13\x4d\x3e\x58\x9a\x1b\x7e\x85\x85\xf6\x01\x5d\xd7\xf1\xb1\xb5\xfc\x37\x0c\x5f\x44\x8d\x7d\xbf\x89\xdd\xa3\x02\x58\xbe\x35\x32\x32\x25\x9b\x41\x37\x4e\x03\x41\x28\x25\x2b\x0d\x8d\x43\xbf\xad\xd1\x83\xb1\xe0\x07\x10\x50\xda\x4b\xdb\xa2\x7b\x00\xff\xe0\x03\xd6\x73\x10\x46\x01\xde\x37\x28\x83\x87\xad\x47\xe7\x21\xd8\x88\xd4\x38\xdb\x6a\x85\x10\x4a\x0a\x73\x28\x03\x01\x3b\xf4\x1e\x6c\x0e\xc2\xec\x30\xf9\xc0\x80\x21\x5b\x13\xb4\x35\xa0\x3d\x38\xcc\x2b\x94\x01\x15\x68\x13\xe1\x08\x86\xaa\xba\xd1\x46\xb8\x87\x98\x96\x4c\xa3\x99\xc6\x32\x32\xdf\x2f\xa3\xf1\x6d\x70\xc2\x78\xea\x39\xa7\xb4\x40\x6c\xf7\x11\x89\x42\x5b\xe1\xb4\xdd\xfa\x5d\xa8\xb4\xc6\x07\xb7\x95\xc1\x3a\x0f\x37\x36\x94\xe3\x91\xa0\xb4\x3e\x2c\xa3\x84\x76\xb3\x60\x2c\x19\xe7\x16\x29\xf1\x9e\xb0\x87\x7f\xab\x98\x83\x6f\xa2\x63\x96\xd2\x6e\x4c\x9d\xce\x21\xa5\xff\x9f\xae\xaf\xd7\x47\x2d\x50\xca\xb7\x32\x9d\xb1\x24\x72\xf2\x79\x24\xda\x9d\x90\x96\xbf\xbc\xfb\xff\x3b\x7a\x29\xae\xd6\xe7\x90\x11\xe8\xec\x19\xd4\x1a\x43\x69\x15\xc0\x69\xd4\x61\x97\x90\xba\xce\x09\x53\x20\x9c\x69\xa3\xf0\x7e\x0e\x67\x1a\x96\x2b\x98\x88\xf3\x39\x3a\xfa\xbe\xef\x3a\x9d\x8f\x4e\xb4\xc0\xca\x23\x3d\xaf\xed\xef\xf6\x0e\x1d\x9c\xe9\x3d\xc7\xba\x0e\x8d\x9a\x1e\xe9\x3c\xf9\x67\x49\xe6\x13\xce\x0f\x92\xd0\x59\x67\x07\x63\xe9\x3a\x7e\x1e\xc7\xfa\xde\x15\x9e\xbf\xaf\xaa\x8f\x34\xfa\xbe\x27\xaf\x24\xb6\x20\xaa\x2c\x23\x01\x4c\x41\x3b\x82\x8f\xf7\x05\x9f\x2e\xa4\x04\xdd\x30\x96\xa8\xb3\x88\xa1\x73\x78\x33\xcd\xfe\xd5\x0a\xd2\x94\xc4\xb3\x83\x98\x93\x27\xac\x60\x7f\x61\xf0\x2f\x78\x97\x4d\x11\x33\x96\xf4\x40\xbd\x03\xc2\x99\x26\xbf\xc7\x91\xd6\x98\x01\x64\xb9\x82\x38\xfb\x5f\xb5\xa8\xb2\xc9\x75\x3e\x18\xbf\xea\x50\x5e\x1a\x8f\x72\xeb\x30\x9b\x1d\x18\xaf\x75\x8d\x76\x1b\x32\xba\xb4\xf9\x06\xa5\x35\x6a\x46\x74\xd0\x79\x04\x7d\xb5\x02\xa3\xab\x98\x29\xc9\xeb\xc0\x3f\x36\x4e\x9b\x90\x67\xd6\xf3\x4d\x50\xe8\xdc\x1c\xd2\x0b\x3a\x2b\xdc\x95\xba\x22\xed\x8a\x4a\x9b\x22\xe2\x93\x50\x0c\x4a\x12\xe9\x12\x5e\xb7\x69\x2c\x93\xb0\x13\xeb\xf9\xc5\xbd\x0e\xd9\xff\x68\xd5\xb3\x24\x51\x98\xa3\x8b\xfe\xfc\xbc\xb2\xb1\xdd\x4f\x5a\xb4\xbf\x8a\x63\x8b\xc8\x79\xdf\x1d\x2a\xf0\xb9\xfa\xe2\x2c\x96\x74\x31\x39\xac\x6d\xc0\x49\x00\xbe\x41\xa9\x73\x8d\xea\x9b\x89\x12\x38\x2c\xab\x67\x27\x5a\xf0\x42\x86\xd7\xed\x37\xb3\x3f\xe5\x31\x1a\x4b\xfc\x9d\x0e\xb2\x84\x37\xa3\xd0\x3a\xd6\x75\x70\xa7\x43\x09\x67\xe1\x22\xb2\x9b\x48\xb7\x27\x3e\x99\xce\xc2\xc5\x53\xce\xd3\xd0\x85\x47\x52\xe2\x29\x9e\xa7\x4b\xea\x70\xd7\xbd\x1d\xc0\xa3\x36\x22\xd0\x01\xcd\x09\x8b\x5e\x0e\x02\xe9\x3b\x43\x81\x91\xe3\x74\xec\x91\xc1\x11\x8b\x7f\x16\xce\x97\x62\xaf\x8d\x21\x41\x14\x14\x2d\x1c\x7e\xdf\xa2\x0f\x13\x0f\x8f\xbe\xb4\xbc\xeb\x0e\xeb\xcb\xba\xee\xa7\x0a\x23\xe5\xf2\x73\x51\x55\x64\x9f\x64\x1c\x69\x74\x82\xa3\x2f\x90\x54\x8a\x2a\xd2\xf3\x47\x05\x3e\x9e\xe3\x23\xba\xc6\x59\x26\x49\x3b\x1d\x76\xf7\x65\x7a\x74\xcc\xf1\xb7\x0e\xff\x20\xe4\x6d\xe1\xec\xd6\x28\xd2\xdd\xd8\xa9\x7f\x59\xfe\xe9\x94\x2f\x17\x3e\x26\x58\x13\x7e\x65\xb2\x74\xe8\x3c\x5c\x0d\x45\xa1\x8a\x94\x59\x46\x2d\x1c\x39\xfe\x77\x23\x3b\x4a\x3f\xfc\xb6\x80\x2b\xf4\x8d\x35\xea\xf9\xf4\xed\x8c\x1d\xf0\xed\x80\x79\x0a\x73\xb1\xad\xc2\xf2\x65\x69\x6a\xd3\x8a\x4a\x2b\x18\xc5\xf7\xfa\x7b\x6c\xd4\xb0\x7a\x2a\xd6\x9e\xb1\xbf\x02\x00\x00\xff\xff\xf6\xa8\x3c\xa8\x1a\x0b\x00\x00")
|
||||
|
||||
func nameServiceNameClientClient_mainGotemplateBytes() ([]byte, error) {
|
||||
return bindataRead(
|
||||
|
@ -94,7 +94,7 @@ func nameServiceNameClientClient_mainGotemplate() (*asset, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "NAME-service/NAME-client/client_main.gotemplate", size: 2837, mode: os.FileMode(436), modTime: time.Unix(1477333032, 0)}
|
||||
info := bindataFileInfo{name: "NAME-service/NAME-client/client_main.gotemplate", size: 2842, mode: os.FileMode(436), modTime: time.Unix(1477698725, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ func nameServiceNameServerServer_mainGotemplate() (*asset, error) {
|
|||
return a, nil
|
||||
}
|
||||
|
||||
var _nameServiceGeneratedClientGrpcClientGotemplate = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\x84\x93\x4d\x6f\xdb\x3c\x0c\xc7\xcf\xd2\xa7\x20\x8c\x1c\x92\x07\xa9\x74\x2f\xd0\x4b\xf3\x64\x45\x81\xad\xcb\xba\xdc\x86\x1d\x14\x99\xb1\x85\x3a\x92\x27\xc9\xc9\x02\xc1\xdf\x7d\xa0\x5f\xf2\x52\xa4\xdb\xc1\x80\x41\xfd\x48\x91\xff\x3f\x25\x25\xac\x94\x7e\x53\x05\x42\xe1\x6b\x0d\xb5\x77\x7b\x93\x63\x00\x05\xc5\xeb\x6a\x01\xba\x32\x68\x23\x6c\x9d\x87\x58\x22\xa4\x24\xbe\xa3\xdf\x1b\x8d\xe2\x09\xe3\x8b\xda\x61\xdb\x42\x18\x22\xbc\xbe\xa8\xc4\xb9\xd9\xd5\xce\x47\x98\x72\x96\x15\xce\x15\x15\x8a\xc2\x55\xca\x16\xc2\xf9\x42\x12\x92\x71\x3a\x32\xb1\x6c\x36\x42\xbb\x9d\x2c\xdc\xdd\x9b\x89\x92\x3e\xb4\x79\xed\x8c\x8d\x19\x67\x44\x46\xaf\x6c\xe8\xaa\x7d\xc0\x9f\x80\x53\x61\x29\x61\x5d\x9a\x00\x43\xbb\x9c\x95\xca\xe6\x15\x7a\xc8\x52\x12\xcf\x5d\x6b\x2b\x15\x4b\xb8\x6b\x5b\x90\xc3\x59\x90\x34\x0a\xfa\x8c\xb3\xb0\xd7\x37\xc9\x02\x2d\x7a\x15\x31\xcf\x38\xab\x37\x1d\xb2\x7a\xbc\x86\x32\x3e\xe3\x5c\x4a\x78\xc1\x03\x78\x8c\x8d\xb7\x01\x94\x1d\x55\x82\x8d\xd2\x6f\x98\xc3\xe6\xf8\x4e\x62\xed\xac\x45\x1d\x8d\xb3\x02\x9e\x23\x98\x40\x82\x53\x1d\x8f\xa1\x76\x36\x98\x8d\xa9\x4c\x3c\x82\xdb\x76\x4e\x68\x55\xd1\x34\xd1\x41\x6e\x54\x35\x07\x65\x73\xa8\x54\x44\x0f\xba\x72\x01\xe7\x3d\x74\xae\xc9\xb7\x8d\xd5\xd4\xd3\x94\x82\xf0\x1f\xe9\x24\x16\xdd\xd5\x0b\x67\xed\x0c\x06\x0d\x46\x7f\x21\x91\x86\xae\xa6\xe4\x00\xf7\x0f\xf0\xe3\xe7\x95\x13\x43\xee\xd7\x1e\x48\x9c\x31\x29\x6f\x01\x8f\xb8\x75\x1e\xa7\xb3\x39\x95\x6b\x39\x67\x29\xdd\xc1\xc1\xc4\x12\x26\x71\x49\x75\x45\xdb\x72\xd6\x45\xbd\xb2\x05\xc2\xc4\x50\x74\x12\x97\xa7\x4d\xfb\x82\xb1\x74\x79\xe8\x38\xb6\x57\x1e\x52\x5a\xbb\xcf\xee\x80\x1e\x26\xe6\xbc\x87\xcb\x61\x67\x60\x5c\x1e\x31\x46\x28\x8f\x3a\xa4\x6b\xfe\x9a\xf9\x00\xd7\x23\xbc\xe0\xa1\x9f\x62\xda\x65\x33\x92\x6e\xde\xff\x66\x29\xad\xbd\xd9\xad\x3c\x6e\xcd\xef\xab\x76\x3f\x35\x55\x75\xfc\xd6\xa8\xca\x6c\x0d\xe6\x74\x03\x64\x22\x6b\xdb\xec\x9c\x79\x79\xf9\x18\x0e\x7b\x2d\x96\x56\xbb\x1c\x9f\x5e\x57\x8b\x6b\xe6\x15\x7f\x35\x18\xe2\x05\xf9\x3f\x7e\x44\x76\xcb\x82\x03\x5a\x6f\x44\x4a\x4f\xae\x6b\x62\x62\xc4\x78\xba\x3e\xd6\x17\x0f\x38\xb5\x03\x7d\xf2\x5b\x08\xd1\x87\x66\x27\x0d\xa7\x33\x0a\xf4\x56\xa1\xcd\xc9\x8c\xf1\x87\xb3\x7e\xcd\xa1\x1f\xa1\xe7\x69\x25\x52\xba\xb4\xf4\xbd\x9f\xf4\x56\xba\x72\xb7\xac\xb8\x07\x80\x7f\xf8\x3c\x3f\x77\xc0\x5a\xde\xf2\x3f\x01\x00\x00\xff\xff\x31\x1b\x3f\x4c\xcb\x04\x00\x00")
|
||||
var _nameServiceGeneratedClientGrpcClientGotemplate = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\x84\x55\xdf\x6f\xdb\x36\x10\x7e\x16\xff\x8a\x9b\x10\x0c\x52\xa0\x50\xef\x1d\xfc\x52\x37\x0d\x3a\x2c\x99\x97\x06\xdb\x43\x51\x0c\x34\x75\x92\x09\xcb\xa4\x46\xd2\x8e\x0d\x41\xff\xfb\x70\x94\x64\x4b\x46\xd2\x3e\x14\xb5\xee\x3e\x7e\xf7\xf3\xbb\xe4\x39\xac\x84\xdc\x8a\x0a\xa1\xb2\x8d\x84\xc6\x9a\x83\x2a\xd0\x81\x80\xea\x79\xb5\x04\x59\x2b\xd4\x1e\x4a\x63\xc1\x6f\x10\xda\x96\x7f\x45\x7b\x50\x12\xf9\x03\xfa\x27\xb1\xc3\xae\x03\x37\x58\x58\x33\x61\x62\x4c\xed\x1a\x63\x3d\x24\x2c\x8a\x2b\x53\x0b\x5d\x71\x63\xab\xfc\x98\x6b\xf4\xb9\x34\xda\xe3\xd1\xc7\xc1\x67\xaa\x1a\xf9\x04\x42\xcf\xdf\xf7\xe4\x3b\xf4\xa2\x10\x5e\x04\x88\xf2\x9b\xfd\x9a\x4b\xb3\xcb\x9b\x6d\x95\xa3\xb5\xc6\xba\x98\xcd\x3d\x95\xb9\xdb\x2a\x9f\xd3\x3f\xd4\x45\x63\x94\xa6\xc0\xc4\xe5\xad\xd0\x2e\x64\xf9\x0e\xfe\x0c\x18\x92\x62\x51\x9e\xc3\xcb\x46\x39\x18\xda\xc0\xa2\x8d\xd0\x45\x8d\x16\xe2\xb6\xe5\x5f\x42\xc9\x2b\xe1\x37\x70\xd7\x75\x90\x0f\x3e\x97\x53\x8b\xd0\xc6\x2c\x72\x07\xf9\x26\xb2\x42\x8d\x56\x78\x2c\x62\x16\x35\xeb\x00\x59\x7d\x9c\x83\x62\x96\x32\x96\xe7\xf0\x84\xaf\x60\xd1\xef\xad\x76\x20\xf4\xd8\x7d\x58\x0b\xb9\xc5\x02\xd6\xa7\xab\xd1\x49\xa3\x35\x4a\xaf\x8c\xe6\xf0\xc5\x83\x72\x34\x48\xe2\xb1\xe8\x1a\xa3\x9d\x5a\xab\x5a\xf9\x13\x98\x32\x4c\x58\x8a\x9a\xaa\xf1\x06\x0a\x25\xea\x0c\x84\x2e\xa0\x16\x1e\x2d\xc8\xda\x38\xcc\x7a\xd0\x84\x13\x58\xb9\xd7\x92\xb2\x4a\xc8\x0c\xb7\xd4\x29\xbe\x0c\xc1\x97\x46\xeb\x0c\x4c\x43\x48\x07\x9c\x0f\xe6\x3f\x83\x21\x85\x64\xe8\xcf\xb8\x53\x19\x84\x01\xa6\xd0\xb2\xe8\x20\x2c\x48\x39\x14\xb1\x34\xba\x54\x15\x63\x11\xed\xe1\xbf\x19\x94\xf0\x61\x01\x56\xe8\x0a\xcf\xe4\x2d\x8b\x22\xb4\x96\x1c\x65\xf2\xab\x94\x29\x8b\x22\x55\x12\x21\xfc\xb2\x00\xad\xea\x80\x88\xfa\xc6\xd1\xf7\x10\xcc\xf1\x7f\xac\x68\x12\xb4\x36\x83\x58\x0a\xad\x8d\x07\xd1\x34\xf5\x69\x60\x8e\x89\xa8\x63\x51\xc7\x58\x24\x27\xd9\x3b\x8a\xf4\xed\xfb\x6c\x8b\x66\xe5\x51\xb8\xb7\xbc\x1f\xb1\x34\x16\x13\x4a\x66\x50\xc1\xdf\xa2\xde\xa3\x7b\x31\x0f\xcf\xab\xe5\xe3\xb0\xdc\x89\x94\x7c\x83\xa2\x40\xeb\xd2\x34\xeb\xc3\xb7\xed\x1d\xbc\x2a\xbf\x81\x1b\x7f\x4f\xd1\x79\xd7\xb1\x28\x58\xfb\x56\xdc\x28\xb2\xde\xf8\xfb\xb3\x46\x1f\xd1\x6f\x4c\xe1\x02\x2e\x74\xb4\x6d\x5f\xcc\x1f\xe6\x15\x2d\xdc\xa8\x8b\x82\xef\x07\x55\xc0\x28\x0f\x3e\x5a\xe8\x5d\xe8\x5b\xf4\x93\x97\x0b\x98\xd7\xfa\x84\xaf\x7d\xb9\xa1\xd0\x50\xaa\xce\xfa\x9f\x71\xdb\xbe\x58\xb5\x5b\x59\x2c\xd5\x71\x96\xee\xe7\x7d\x5d\x9f\xfe\xda\x8b\x5a\x95\x0a\x0b\x8a\x00\x31\x8f\xbb\x2e\xbe\xbc\x9c\x06\x1f\xcd\xee\x20\xf9\xbd\x96\xa6\x40\xea\xe0\x1c\xf3\x8c\xff\xed\xd1\xf9\x09\xf2\x13\xbe\x87\x0c\x72\xc0\x01\xda\xac\x79\xdb\x3e\x98\x90\xc4\x8d\xe2\xa3\xf7\xe5\xd4\x4c\x4e\x5f\xdb\x0d\xe8\xd9\x66\x70\xce\x7b\x73\x7a\xee\x63\x42\x5b\x14\xf5\xe3\x42\x5d\xd0\x40\xc6\x1f\x6c\xdc\xc9\xbe\x8c\x1e\xef\x5a\x02\x4c\xc7\x7a\x3d\x53\xba\x08\x81\xee\xad\x71\x7c\x00\x80\x9f\xcc\x3a\xbb\x64\x10\x75\x19\x09\x82\x75\x8c\xf9\x53\x83\x33\xcd\x81\xf3\x76\x2f\x3d\x89\x67\x58\x47\xf8\xf6\xdd\x79\xab\x74\x45\xf8\x3c\x87\xe9\xce\xd3\x75\x11\x40\xf7\x20\x7c\xf9\x8d\xf0\xb0\x33\x05\x8d\xd3\xf5\x87\xe3\x7c\x93\x48\xcf\x21\xda\xec\x3d\x3d\x4d\x6e\xa7\x09\xa4\xbd\x4c\x59\x7f\x65\x96\xfe\x38\xaa\xe5\x2b\xea\x22\xd9\xe2\x29\xdc\x95\x3e\xa3\x74\x4e\xd6\x9e\x5b\x1b\x68\x0d\xbc\x45\x1c\xce\x82\x19\xb5\x06\x0b\x20\x4a\x36\x3d\x14\x24\xbe\x6e\x88\xff\x23\xc5\x86\x5c\xc6\xe6\xa4\x57\x7a\x18\xf6\xf0\x33\x91\x5c\xe5\x25\xfd\x71\xe4\xe5\xcb\xfe\xff\x0c\x76\x05\xdc\x8e\x7f\xe8\xf8\xe3\xa7\xf4\x1a\x11\xd2\x26\x45\x37\x42\x4d\x67\x12\x8d\x27\x72\x7b\x39\x91\x21\xb1\xa0\x62\x55\xc2\x21\x03\x13\x7c\xd2\x1f\x79\xa8\x23\xd9\xa6\x3c\x19\xb2\xfe\x8d\x9c\xbd\xe0\x7b\xe2\x05\x1d\x43\xea\x74\xf8\xcc\x60\x9b\xc1\xe1\xbc\xcb\xb4\xbc\xc4\xd9\x43\xa7\x67\xf6\x76\x57\xc0\x02\xce\x05\xfc\x6e\x94\x4e\x6e\x77\x45\x76\x31\xad\xe8\x4d\xcf\xca\x39\x4f\xd3\x91\x6e\xe8\x8c\xf4\xc7\xbe\xef\xff\x07\x00\x00\xff\xff\x98\xe6\x41\x14\xa1\x08\x00\x00")
|
||||
|
||||
func nameServiceGeneratedClientGrpcClientGotemplateBytes() ([]byte, error) {
|
||||
return bindataRead(
|
||||
|
@ -134,7 +134,7 @@ func nameServiceGeneratedClientGrpcClientGotemplate() (*asset, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "NAME-service/generated/client/grpc/client.gotemplate", size: 1227, mode: os.FileMode(436), modTime: time.Unix(1477359850, 0)}
|
||||
info := bindataFileInfo{name: "NAME-service/generated/client/grpc/client.gotemplate", size: 2209, mode: os.FileMode(436), modTime: time.Unix(1477698951, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ func nameServiceGeneratedClientHttpClientGotemplate() (*asset, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "NAME-service/generated/client/http/client.gotemplate", size: 105, mode: os.FileMode(436), modTime: time.Unix(1477435906, 0)}
|
||||
info := bindataFileInfo{name: "NAME-service/generated/client/http/client.gotemplate", size: 105, mode: os.FileMode(436), modTime: time.Unix(1477696627, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ func nameServiceGeneratedEndpointsGotemplate() (*asset, error) {
|
|||
return a, nil
|
||||
}
|
||||
|
||||
var _nameServiceGeneratedTransport_grpcGotemplate = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xac\x55\xc1\x6e\xe3\x36\x10\x3d\x8b\x5f\x31\x35\x82\xc2\x5e\xd8\xd4\x3d\x40\x2e\x9b\x6e\xd3\x05\xba\x5b\x23\xcd\xad\x28\x16\xb4\x3c\x96\x89\xc8\x24\x43\xd2\xde\xb8\x84\xfe\xbd\x18\x52\xb2\xe5\xd8\xb1\x9c\x20\x87\x40\x31\xf5\x38\x33\xef\xbd\x99\x91\x11\xc5\xa3\x28\x11\xdc\xa6\x60\x2c\xcf\xe1\x61\x29\x1d\x2c\x64\x85\x60\xac\xde\xc8\x39\x3a\x70\x68\x37\x68\x27\x4e\xce\x11\x66\x52\xcd\xa5\x2a\x1d\x2c\xb4\x05\xbf\x44\x28\xef\xa7\xb7\xe0\xad\x50\xce\x68\xeb\x39\x85\xf8\xea\x61\xed\x65\x25\xff\x43\x17\x21\xbb\xb7\x79\x69\x4d\xc1\xff\x8e\xe1\x38\x63\x72\x45\x87\x30\x64\xd9\xa0\xd4\x95\x50\x25\xd7\xb6\xcc\x9f\x73\x85\x3e\x2f\xb4\xf2\xf8\xec\x07\x8c\x65\x74\x69\x17\x02\x06\xa5\xf4\xcb\xf5\x8c\x17\x7a\x95\x97\x7a\xf2\x28\x7d\x4e\x7f\x87\x39\xe8\x5a\xcb\x85\xd2\xc9\x02\x59\x66\x66\x30\x08\x81\x4f\x3f\x7f\x8d\x79\xa7\xc2\x2f\x61\x52\xd7\x03\x36\x62\x91\xf9\x37\xf1\x88\x77\xf7\xd3\xdb\x54\x1f\xac\xc4\x23\x3a\x10\xe0\xd0\x83\x5e\x00\xaa\xb9\xd1\x52\x79\x07\x62\x23\x64\x25\x66\x15\x82\xa0\xf7\x51\x80\x10\xee\xf4\x77\xb1\x42\xe0\x4d\x3a\x7e\x87\x9e\x0e\xea\xba\xa5\xbb\x58\xab\xe2\x45\x8e\x61\xe1\x9f\xa1\x61\xca\x6f\xd3\x73\xdc\xc9\xf4\xa5\xfd\x6f\x04\x66\xc6\x7b\x73\x40\x20\xd6\xda\x78\xa9\x95\x83\xeb\x1b\xf8\xe7\xdf\x03\xed\x1a\xe5\xff\x8a\x80\xc0\x32\x92\xe8\x18\x20\x0b\xfc\x8c\x0b\x6d\x71\x38\xa2\x70\x35\xcb\x2c\xfa\xb5\x55\xf0\x2b\x61\x53\x88\x98\x08\x42\x80\x07\xfd\xa7\xfe\x89\xf6\xa8\x24\xa8\x6b\x96\x85\x60\x85\x2a\x11\xae\x24\x15\xb3\x83\x7c\x43\xbf\xd4\x73\x47\x88\x2c\x84\x36\xc2\x95\xdc\xd3\xb9\x7e\x51\xd6\x77\xfc\xd9\x08\xc6\xb2\x2c\x2b\xfc\xf3\x98\x9e\x3b\x9d\x78\x08\xdd\xdb\xad\x6a\x11\xf4\x1b\x16\x7a\x1e\x25\x3f\x04\xdd\xe3\xd3\x1a\x5d\xc2\x7c\x51\xaf\x61\x9c\xd1\xca\x61\x04\xed\x84\xe5\x9c\xd3\xc1\x68\x4c\x04\x27\xe4\x16\x31\xa9\x59\x1d\x9b\x68\xaf\x11\xc8\x95\xa9\x70\x85\x64\x24\x4d\x41\xbf\x7d\x52\x79\xb4\x0b\x51\x20\xf3\x5b\x83\xdd\x50\xce\xdb\x75\xe1\x21\xb0\x7e\x49\x4f\x2b\x0a\xf0\x42\xd2\x3f\x84\x9a\x57\x68\xd9\x9e\x42\xaa\xbf\x89\x14\xc7\xbb\x53\x80\xd7\x7b\x3a\x6f\x62\xd2\x5b\x70\x1c\x8b\xa1\x83\x4f\xfb\x6c\xa3\x7d\x86\x2e\x87\xd3\xd3\x62\xf1\x09\x3e\x75\xa7\xe3\x4a\xf2\xc6\xdc\x87\xad\xe9\x94\x36\x82\xe1\x31\x2e\x19\x7c\x08\x1c\x03\x5a\xab\xa9\x0a\x96\xfd\xa0\x04\x26\x9e\x50\xfd\xd4\x6a\xa7\xe4\x4d\x93\x45\x1d\x44\x45\xc6\xa2\x46\x2c\x93\x8b\x78\xef\x97\x1b\x50\xb2\xa2\x68\xed\x24\x29\x59\xc5\x90\xd4\x36\xed\x99\x45\xc3\x2f\x2c\x70\x34\xa6\x08\xac\x66\x21\x24\xeb\xc8\xb8\x46\xf9\xd4\xef\xfd\xb2\xe7\x39\xf4\x8c\x06\x48\xda\x6e\x2f\x76\x77\xba\xd3\x20\x7e\x27\xeb\xfc\x52\x78\x72\x65\x83\x96\x76\x63\x9c\x81\xb4\x11\x4f\xf6\xa1\x6d\x82\x7b\x0d\x02\xd6\x0e\xed\x64\xae\x57\x42\xaa\x1e\x3c\x87\xa9\x95\x2b\x61\x65\xb5\xa5\x5b\x8b\x75\x05\x52\xc5\xe5\xdc\x59\xae\x3d\x84\x86\x3f\x8e\xbb\x87\x48\xdd\xe3\xd3\xbe\x61\x03\xf5\x49\xe7\x57\xb7\x19\xa8\xd5\xae\x6f\xda\x3b\xa7\xdc\x3a\xd5\x76\x1d\x87\x9f\x8e\x8c\x23\xb9\x6e\x2b\x49\x53\xf5\x21\xce\xa5\x76\x39\x6b\x5d\x82\xbc\xcf\x3b\x53\x6d\xdf\xe0\x5c\xca\xf4\x9a\x75\x45\xa4\xdd\x6b\x5d\x0a\xf2\xba\x77\x54\xd2\x85\xee\x11\x74\xe7\x9f\xa9\xb6\x17\xcf\x5b\x77\x48\xab\xed\x99\xe9\x4b\x5f\x92\x8b\x3c\xec\xfb\xe8\x9c\xf4\x30\x5d\xea\xf3\xf0\x0d\xe6\x24\x37\x7b\x4d\xbf\x68\xfc\xfa\x18\x9d\xf2\x70\x57\xc7\x85\x16\x3a\x43\x8a\xee\x5a\xeb\x1d\x06\x3a\x73\x6e\x08\x3f\xc4\xc0\xd7\xd7\x67\xeb\xdf\xd9\xf5\x79\xf9\x56\xbc\xc4\xbd\xb3\xeb\xf3\x60\x06\x7b\x08\x9d\xb6\xaf\xe1\xfa\x86\xf5\xd9\x96\xf4\x11\xeb\xf3\xff\x00\x00\x00\xff\xff\x3f\x3f\xdb\x65\xbd\x0c\x00\x00")
|
||||
var _nameServiceGeneratedTransport_grpcGotemplate = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xac\x57\xdf\x6f\xdb\x36\x10\x7e\x16\xff\x8a\x9b\x51\x0c\x76\xe0\x48\x7b\x0e\x90\x97\xa6\x5d\x52\x6c\xe9\x82\x2c\xd8\x1e\x8a\xa2\xa0\xa5\xb3\x44\x98\x22\x15\x92\x76\xe2\x09\xfa\xdf\x87\x23\x25\x5b\x4e\x94\xc8\x29\xf2\x50\xb8\x91\xee\xc7\x77\xdf\x77\x77\xa4\x2a\x9e\xae\x78\x8e\x60\x37\x29\x63\x49\x02\x77\x85\xb0\xb0\x14\x12\xa1\x32\x7a\x23\x32\xb4\x60\xd1\x6c\xd0\x9c\x5a\x91\x21\x2c\x84\xca\x84\xca\x2d\x2c\xb5\x01\x57\x20\xe4\xb7\x37\x17\xe0\x0c\x57\xb6\xd2\xc6\xc5\x14\xe2\x8b\x83\xb5\x13\x52\xfc\x87\xd6\x9b\xec\xde\x26\xb9\xa9\xd2\xf8\x6f\x1f\x2e\x66\x4c\x94\xf4\x10\xa6\x2c\x9a\x28\x74\x49\xe1\x5c\x35\x61\x2c\x9a\xe4\x5a\x72\x95\xc7\xda\xe4\xc9\x63\x42\x6f\x52\xad\x1c\x3e\xba\x89\x7f\xa7\x73\x89\x71\xcf\x84\x62\x26\x25\x3a\x9e\x71\xc7\xc9\x9f\x1e\xec\x52\xc2\x24\x17\xae\x58\x2f\xe2\x54\x97\x49\xae\x4f\x57\xc2\x25\xf4\xef\x10\x13\xb9\x75\xb5\x13\x3c\x91\x22\x8b\xaa\x05\x4c\xea\x3a\xbe\xf9\xf8\xc5\xe3\xbc\xe1\xae\x80\xd3\xa6\x99\xb0\x19\xf3\x4c\x5d\xf3\x15\x5e\xde\xde\x5c\x84\x7a\xa0\xe4\x2b\xb4\xc0\xc1\xa2\x03\xbd\x04\x54\x59\xa5\x85\x72\x16\xf8\x86\x0b\xc9\x17\x12\x81\xd3\x7b\x4f\x58\x5d\x5f\xea\xaf\xbc\x44\x88\xdb\x74\xf1\x25\x3a\x7a\xd0\x34\x1d\x3d\xcb\xb5\x4a\x9f\xe4\x98\xa6\xee\x11\x5a\x32\xe2\x8b\xf0\x3b\xef\x65\xfa\xdc\xfd\x6f\x06\xd5\x22\x1e\xcd\x01\x35\x8b\x82\xb6\x7f\x55\x4e\x68\x65\xe1\xec\x1c\xbe\x7d\x3f\xe0\xaf\x55\x2b\x18\xd4\x2c\x8a\x60\xe8\xf5\x47\x5c\x6a\x83\xd3\x4e\x85\x3b\xdd\x82\x9b\xcd\x59\xd4\xb0\xc8\xa0\x5b\x1b\x05\xbf\x92\x6b\x70\xa8\x3d\xdf\x75\x0d\x77\xfa\x4f\xfd\x80\xe6\x19\x46\x68\x1a\x16\xd5\xb5\xe1\x2a\x47\xf8\x20\x08\xd9\xce\xe4\x1a\x5d\xa1\x33\x4b\x16\x51\x5d\x77\x11\x3e\x88\x7d\x7d\x67\x4f\x50\x7e\xc5\x87\x96\x41\x16\x45\x51\xea\x1e\xe7\xf4\xbb\x23\x2e\xae\xeb\xbe\x77\x47\xa3\x37\xfa\x84\xa9\xce\xbc\x06\x87\x46\xb7\x78\xbf\x46\x1b\x6c\x3e\xab\x97\x6c\x6c\xa5\x95\x45\x6f\x74\xc0\x74\x1c\xc7\xf4\x90\xf8\xa9\xeb\x53\x92\x90\xaa\x69\x58\xe3\x3b\x6b\xcf\x13\x88\xb2\x92\x58\x22\xa9\x4b\xa3\x34\xae\xa9\x50\x0e\xcd\x92\xa7\xc8\xdc\xb6\xc2\x7e\x28\xeb\xcc\x3a\x75\x50\xb3\x71\x5a\x87\x59\x05\x78\x42\xeb\x15\x57\x99\x44\xc3\xf6\x25\x04\xfc\x6d\x24\xbf\x23\x7a\x00\x9c\xde\x97\xf3\xa6\x4a\x46\x01\xfb\x59\x99\x5a\x38\xd9\x67\x9b\xed\x33\xf4\x6b\x18\x1e\x21\x83\xf7\x70\xd2\x1f\x99\x0f\x22\x6e\x05\xbe\xdb\x56\x3d\x68\x33\x98\x3e\xb7\x0b\x22\x1f\x1a\xce\x01\x8d\xd1\x84\x82\x45\x3f\x28\x41\xe5\x9f\x10\x7e\x6a\xb7\x21\x7a\xc3\x2c\x51\x17\x11\x48\x0f\x6a\xc6\x22\xb1\xf4\x7e\xbf\x9c\x83\x12\x92\xa2\x75\xd3\xa4\x84\xf4\x21\xfb\x13\x66\xb0\x8a\x8f\x04\x38\x9b\x53\x04\xd6\xb0\xba\x0e\xd2\x91\x70\x2d\xf3\xa1\xe7\xc7\x69\x4f\x12\x18\x19\x0f\x10\xb4\xf2\x9e\x1c\x00\xc1\xa7\xb5\xf8\x9d\xa4\x73\x05\x77\xa4\xca\x06\x0d\x2d\x4c\x3f\x03\x61\x4d\x0e\xf6\xa1\x69\x83\x3b\x0d\x1c\xd6\x16\xcd\x69\xa6\x4b\x2e\xd4\x88\x7d\x0c\x37\x46\x94\xdc\x08\xb9\x25\xaf\xe5\x5a\x82\x50\x7e\x63\xf7\x36\xee\x48\x41\xd3\x1f\xcf\xbb\x87\x8a\xba\xc5\xfb\x7d\xc3\xd6\xd4\x27\xbd\xbf\xfa\xcd\x40\xad\x76\x76\xde\xf9\x0c\xa9\x35\xd4\x76\x3d\x85\xef\x9f\x09\x47\x74\x5d\x48\x41\x53\xf5\x2e\xca\x85\x76\x79\x55\xba\x60\xf2\x73\xda\x55\x72\xfb\x06\xe5\x42\xa6\x97\xa4\x4b\x7d\xd9\xa3\xd2\x85\x20\x2f\x6b\x47\x90\x8e\x54\x8f\x4c\x77\xfa\x55\x72\x7b\xf4\xbc\xf5\x87\x54\x6e\x5f\x99\xbe\x70\x9a\x1c\xa5\xe1\xd8\xc1\x33\xa8\x61\x70\x1a\xd3\xf0\x0d\xe2\x04\x35\x47\x45\x3f\x6a\xfc\xc6\x2a\x1a\xd2\x70\x87\xe3\x48\x09\x6d\x45\x8c\xee\x5a\xeb\x27\x04\xb4\xd5\x6b\x43\xf8\x2e\x02\xbe\xbc\x3e\x3b\xfd\x5e\x5d\x9f\xc7\x6f\xc5\x63\xd4\x7b\x75\x7d\x1e\xcc\xe0\x48\x41\xc3\xf2\xb5\xb5\xbe\x61\x7d\x76\x90\xde\x63\x7d\x26\x09\x5c\xa1\xac\xd0\x58\x16\x6a\x78\x76\x8d\x1d\xbe\x34\x94\x19\x9c\x74\xa6\xf1\xf5\xa7\xd9\x53\x0b\x82\x4b\x37\xa0\xd5\x1c\x36\x1e\xb3\xef\x86\x93\x32\xf3\xa7\xb8\x58\xc2\xa6\x7f\xaa\x87\xef\x0f\x84\x15\x6e\xbd\xea\x59\x86\x19\x2c\xb4\x2b\x88\xe4\x2e\x0d\xdd\xa8\x4a\xee\x60\xba\x9a\xc1\x43\x21\xd2\xc2\x9b\x4a\x09\x92\x54\x6b\xa3\x70\x95\xf9\xbb\x22\x7d\x4f\xc5\x17\x5c\x69\x25\x52\x2e\xaf\x90\x67\x68\xfe\xc0\x2d\x7d\x9c\xb8\x36\x91\xd5\xa1\x77\x84\x83\x94\x2b\x58\x60\x17\x22\x4d\xd1\x5a\xcc\x28\x37\x0a\x57\xa0\x69\x33\xb7\xd7\x67\x38\xdf\x15\xfb\xaf\x70\xc5\x3f\x5c\xae\x31\x5c\x5a\xa8\xd8\x6f\xbf\x7d\x9f\x8d\x1a\xbe\x80\x6e\xba\x9a\xed\x23\xf8\x2b\xf1\x4e\xbb\xd4\x3d\xb2\x86\xfd\x1f\x00\x00\xff\xff\xba\xba\x12\xdf\xb0\x0e\x00\x00")
|
||||
|
||||
func nameServiceGeneratedTransport_grpcGotemplateBytes() ([]byte, error) {
|
||||
return bindataRead(
|
||||
|
@ -194,7 +194,7 @@ func nameServiceGeneratedTransport_grpcGotemplate() (*asset, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "NAME-service/generated/transport_grpc.gotemplate", size: 3261, mode: os.FileMode(436), modTime: time.Unix(1477333032, 0)}
|
||||
info := bindataFileInfo{name: "NAME-service/generated/transport_grpc.gotemplate", size: 3760, mode: os.FileMode(436), modTime: time.Unix(1477708246, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ func nameServiceGeneratedTransport_httpGotemplate() (*asset, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "NAME-service/generated/transport_http.gotemplate", size: 105, mode: os.FileMode(436), modTime: time.Unix(1477435906, 0)}
|
||||
info := bindataFileInfo{name: "NAME-service/generated/transport_http.gotemplate", size: 105, mode: os.FileMode(436), modTime: time.Unix(1477696627, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
|
|
|
@ -3,24 +3,24 @@ OK_COLOR=\e[38;5;118m
|
|||
UNDER=\n________________________________________________________________________________\n
|
||||
END_COLOR_LINE=$(UNDER)$(NO_COLOR)
|
||||
|
||||
HTTPTEST_MSG=\n$(OK_COLOR)Starting http end to end test:$(END_COLOR_LINE)
|
||||
TRANSPORT_TEST_MSG=\n$(OK_COLOR)Starting transport end to end test:$(END_COLOR_LINE)
|
||||
|
||||
CLITEST_MSG=\n$(OK_COLOR)Start server and cliclient generate, build, and run test:$(END_COLOR_LINE)
|
||||
CLI_TEST_MSG=\n$(OK_COLOR)Start server and cliclient generate, build, and run test:$(END_COLOR_LINE)
|
||||
|
||||
|
||||
all: test
|
||||
|
||||
test: clean test-http test-cli
|
||||
test: clean test-transport test-cli
|
||||
|
||||
test-http:
|
||||
@printf '$(HTTPTEST_MSG)'
|
||||
$(MAKE) -C http
|
||||
test-transport:
|
||||
@printf '$(TRANSPORT_TEST_MSG)'
|
||||
$(MAKE) -C transport
|
||||
|
||||
test-cli:
|
||||
@printf '$(CLITEST_MSG)'
|
||||
@printf '$(CLI_TEST_MSG)'
|
||||
go test -v ./cli
|
||||
|
||||
clean:
|
||||
go test ./cli -clean
|
||||
$(MAKE) -C http clean
|
||||
$(MAKE) -C transport clean
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ END_COLOR_LINE=$(UNDER)$(NO_COLOR)
|
|||
|
||||
TRUSS_MSG=\n$(OK_COLOR)Running Truss...$(END_COLOR_LINE)
|
||||
|
||||
TEST_RUNNING_MSG=\n$(OK_COLOR)Running http tests:$(END_COLOR_LINE)
|
||||
TEST_RUNNING_MSG=\n$(OK_COLOR)Running transport tests:$(END_COLOR_LINE)
|
||||
|
||||
TRUSS_AGAIN_MSG=\n$(OK_COLOR)Running Truss... again, to test regeneration$(END_COLOR_LINE)
|
||||
|
||||
|
@ -13,16 +13,15 @@ all: test
|
|||
|
||||
test:
|
||||
@echo -e '$(TRUSS_MSG)'
|
||||
truss httptest.proto
|
||||
cp -r handlers httptest-service
|
||||
truss transport-test.proto
|
||||
cp -r handlers transport-service
|
||||
@echo -e '$(TEST_RUNNING_MSG)'
|
||||
go test -v
|
||||
@echo -e '$(TRUSS_AGAIN_MSG)'
|
||||
truss httptest.proto
|
||||
truss transport-test.proto
|
||||
@echo -e '$(TEST_RUNNING_MSG)'
|
||||
go test -v
|
||||
$(MAKE) clean
|
||||
|
||||
clean:
|
||||
rm -rf httptest-service
|
||||
rm -rf third_party
|
||||
rm -rf transport-service
|
|
@ -0,0 +1,56 @@
|
|||
package test
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
pb "github.com/TuneLab/go-truss/truss/_integration-tests/transport/transport-service"
|
||||
grpcclient "github.com/TuneLab/go-truss/truss/_integration-tests/transport/transport-service/generated/client/grpc"
|
||||
)
|
||||
|
||||
var grpcAddr string
|
||||
|
||||
func init() { _ = grpcAddr }
|
||||
|
||||
func TestCtxToCtxViaGRPCMetadata(t *testing.T) {
|
||||
var req pb.MetaRequest
|
||||
var key, value = "Truss-Auth-Header", "SECRET"
|
||||
req.Key = key
|
||||
|
||||
// Create a new client telling it to send "Truss-Auth-Header" as a header
|
||||
conn, err := grpc.Dial(grpcAddr, grpc.WithInsecure(), grpc.WithTimeout(time.Second))
|
||||
svcgrpc, err := grpcclient.New(conn,
|
||||
grpcclient.CtxValuesToSend(key))
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create grpcclient: %q", err)
|
||||
}
|
||||
|
||||
// Create a context with the header key and valu
|
||||
ctx := context.WithValue(context.Background(), key, value)
|
||||
|
||||
// send the context
|
||||
resp, err := svcgrpc.CtxToCtx(ctx, &req)
|
||||
if err != nil {
|
||||
t.Fatalf("grpcclient returned error: %q", err)
|
||||
}
|
||||
|
||||
if resp.V != value {
|
||||
t.Fatalf("Expect: %q, got %q", value, resp.V)
|
||||
}
|
||||
|
||||
// Test the key in the ToLower format as metadata sends that over the wire
|
||||
req.Key = strings.ToLower(req.Key)
|
||||
// send the context
|
||||
resp, err = svcgrpc.CtxToCtx(ctx, &req)
|
||||
if err != nil {
|
||||
t.Fatalf("grpcclient returned error: %q", err)
|
||||
}
|
||||
|
||||
if resp.V != value {
|
||||
t.Fatalf("Expect: %q, got %q", value, resp.V)
|
||||
}
|
||||
}
|
|
@ -4,26 +4,20 @@ package handler
|
|||
// implementation. It also includes service middlewares.
|
||||
|
||||
import (
|
||||
_ "errors"
|
||||
_ "time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
|
||||
_ "github.com/go-kit/kit/log"
|
||||
_ "github.com/go-kit/kit/metrics"
|
||||
|
||||
pb "github.com/TuneLab/go-truss/truss/_integration-tests/http/httptest-service"
|
||||
pb "github.com/TuneLab/go-truss/truss/_integration-tests/transport/transport-service"
|
||||
)
|
||||
|
||||
// NewService returns a naïve, stateless implementation of Service.
|
||||
func NewService() Service {
|
||||
return httptestService{}
|
||||
return transportService{}
|
||||
}
|
||||
|
||||
type httptestService struct{}
|
||||
type transportService struct{}
|
||||
|
||||
// GetWithQuery implements Service.
|
||||
func (s httptestService) GetWithQuery(ctx context.Context, in *pb.GetWithQueryRequest) (*pb.GetWithQueryResponse, error) {
|
||||
func (s transportService) GetWithQuery(ctx context.Context, in *pb.GetWithQueryRequest) (*pb.GetWithQueryResponse, error) {
|
||||
response := pb.GetWithQueryResponse{
|
||||
V: in.A + in.B,
|
||||
}
|
||||
|
@ -32,7 +26,7 @@ func (s httptestService) GetWithQuery(ctx context.Context, in *pb.GetWithQueryRe
|
|||
}
|
||||
|
||||
// GetWithRepeatedQuery implements Service.
|
||||
func (s httptestService) GetWithRepeatedQuery(ctx context.Context, in *pb.GetWithRepeatedQueryRequest) (*pb.GetWithRepeatedQueryResponse, error) {
|
||||
func (s transportService) GetWithRepeatedQuery(ctx context.Context, in *pb.GetWithRepeatedQueryRequest) (*pb.GetWithRepeatedQueryResponse, error) {
|
||||
var out int64
|
||||
|
||||
for _, v := range in.A {
|
||||
|
@ -47,17 +41,17 @@ func (s httptestService) GetWithRepeatedQuery(ctx context.Context, in *pb.GetWit
|
|||
}
|
||||
|
||||
// PostWithNestedMessageBody implements Service.
|
||||
func (s httptestService) PostWithNestedMessageBody(ctx context.Context, in *pb.PostWithNestedMessageBodyRequest) (*pb.PostWithNestedMessageBodyResponse, error) {
|
||||
func (s transportService) PostWithNestedMessageBody(ctx context.Context, in *pb.PostWithNestedMessageBodyRequest) (*pb.PostWithNestedMessageBodyResponse, error) {
|
||||
response := pb.PostWithNestedMessageBodyResponse{
|
||||
V: in.NM.A + in.NM.B,
|
||||
}
|
||||
return &response, nil
|
||||
}
|
||||
|
||||
// CtxtToCtxtViaHTTPHeader implements Service.
|
||||
func (s httptestService) CtxToCtxViaHTTPHeader(ctx context.Context, in *pb.HeaderRequest) (*pb.HeaderResponse, error) {
|
||||
var resp pb.HeaderResponse
|
||||
val := ctx.Value(in.HeaderKey)
|
||||
// CtxToCtx implements Service.
|
||||
func (s transportService) CtxToCtx(ctx context.Context, in *pb.MetaRequest) (*pb.MetaResponse, error) {
|
||||
var resp pb.MetaResponse
|
||||
val := ctx.Value(in.Key)
|
||||
|
||||
if v, ok := val.(string); ok {
|
||||
resp.V = v
|
||||
|
@ -74,5 +68,5 @@ type Service interface {
|
|||
GetWithQuery(ctx context.Context, in *pb.GetWithQueryRequest) (*pb.GetWithQueryResponse, error)
|
||||
GetWithRepeatedQuery(ctx context.Context, in *pb.GetWithRepeatedQueryRequest) (*pb.GetWithRepeatedQueryResponse, error)
|
||||
PostWithNestedMessageBody(ctx context.Context, in *pb.PostWithNestedMessageBodyRequest) (*pb.PostWithNestedMessageBodyResponse, error)
|
||||
CtxToCtxViaHTTPHeader(ctx context.Context, in *pb.HeaderRequest) (*pb.HeaderResponse, error)
|
||||
CtxToCtx(ctx context.Context, in *pb.MetaRequest) (*pb.MetaResponse, error)
|
||||
}
|
|
@ -6,58 +6,23 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
|
||||
// 3d Party
|
||||
"golang.org/x/net/context"
|
||||
|
||||
// Go Kit
|
||||
"github.com/go-kit/kit/log"
|
||||
|
||||
// This Service
|
||||
pb "github.com/TuneLab/go-truss/truss/_integration-tests/http/httptest-service"
|
||||
svc "github.com/TuneLab/go-truss/truss/_integration-tests/http/httptest-service/generated"
|
||||
httpclient "github.com/TuneLab/go-truss/truss/_integration-tests/http/httptest-service/generated/client/http"
|
||||
handler "github.com/TuneLab/go-truss/truss/_integration-tests/http/httptest-service/handlers/server"
|
||||
pb "github.com/TuneLab/go-truss/truss/_integration-tests/transport/transport-service"
|
||||
httpclient "github.com/TuneLab/go-truss/truss/_integration-tests/transport/transport-service/generated/client/http"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var httpserver *httptest.Server
|
||||
// httpTestServer
|
||||
|
||||
var _ = io.Copy
|
||||
|
||||
func init() {
|
||||
var logger log.Logger
|
||||
logger = log.NewNopLogger()
|
||||
|
||||
var service handler.Service
|
||||
{
|
||||
service = handler.NewService()
|
||||
}
|
||||
|
||||
// Endpoint domain.
|
||||
getWithQueryE := svc.MakeGetWithQueryEndpoint(service)
|
||||
getWithRepeatedQueryE := svc.MakeGetWithRepeatedQueryEndpoint(service)
|
||||
postWithNestedMessageBodyE := svc.MakePostWithNestedMessageBodyEndpoint(service)
|
||||
ctxToCtxViaHTTPHeaderE := svc.MakeCtxToCtxViaHTTPHeaderEndpoint(service)
|
||||
|
||||
endpoints := svc.Endpoints{
|
||||
GetWithQueryEndpoint: getWithQueryE,
|
||||
GetWithRepeatedQueryEndpoint: getWithRepeatedQueryE,
|
||||
PostWithNestedMessageBodyEndpoint: postWithNestedMessageBodyE,
|
||||
CtxToCtxViaHTTPHeaderEndpoint: ctxToCtxViaHTTPHeaderE,
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
h := svc.MakeHTTPHandler(ctx, endpoints, logger)
|
||||
httpserver = httptest.NewServer(h)
|
||||
}
|
||||
var httpAddr string
|
||||
|
||||
func TestGetWithQueryClient(t *testing.T) {
|
||||
var req pb.GetWithQueryRequest
|
||||
|
@ -65,7 +30,7 @@ func TestGetWithQueryClient(t *testing.T) {
|
|||
req.B = 45360
|
||||
want := req.A + req.B
|
||||
|
||||
svchttp, err := httpclient.New(httpserver.URL)
|
||||
svchttp, err := httpclient.New(httpAddr)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create httpclient: %q", err)
|
||||
}
|
||||
|
@ -116,7 +81,7 @@ func TestGetWithRepeatedQueryClient(t *testing.T) {
|
|||
req.A = []int64{12, 45360}
|
||||
want := req.A[0] + req.A[1]
|
||||
|
||||
svchttp, err := httpclient.New(httpserver.URL)
|
||||
svchttp, err := httpclient.New(httpAddr)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create httpclient: %q", err)
|
||||
}
|
||||
|
@ -174,7 +139,7 @@ func TestPostWithNestedMessageBodyClient(t *testing.T) {
|
|||
req.NM = &reqNM
|
||||
want := req.NM.A + req.NM.B
|
||||
|
||||
svchttp, err := httpclient.New(httpserver.URL)
|
||||
svchttp, err := httpclient.New(httpAddr)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create httpclient: %q", err)
|
||||
}
|
||||
|
@ -223,12 +188,12 @@ func TestPostWithNestedMessageBodyRequest(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCtxToCtxViaHTTPHeaderClient(t *testing.T) {
|
||||
var req pb.HeaderRequest
|
||||
var req pb.MetaRequest
|
||||
var key, value = "Truss-Auth-Header", "SECRET"
|
||||
req.HeaderKey = key
|
||||
req.Key = key
|
||||
|
||||
// Create a new client telling it to send "Truss-Auth-Header" as a header
|
||||
svchttp, err := httpclient.New(httpserver.URL,
|
||||
svchttp, err := httpclient.New(httpAddr,
|
||||
httpclient.CtxValuesToSend(key))
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create httpclient: %q", err)
|
||||
|
@ -238,7 +203,7 @@ func TestCtxToCtxViaHTTPHeaderClient(t *testing.T) {
|
|||
ctx := context.WithValue(context.Background(), key, value)
|
||||
|
||||
// send the context
|
||||
resp, err := svchttp.CtxToCtxViaHTTPHeader(ctx, &req)
|
||||
resp, err := svchttp.CtxToCtx(ctx, &req)
|
||||
if err != nil {
|
||||
t.Fatalf("httpclient returned error: %q", err)
|
||||
}
|
||||
|
@ -249,13 +214,13 @@ func TestCtxToCtxViaHTTPHeaderClient(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCtxToCtxViaHTTPHeaderRequest(t *testing.T) {
|
||||
var resp pb.HeaderResponse
|
||||
var resp pb.MetaResponse
|
||||
var key, value = "Truss-Auth-Header", "SECRET"
|
||||
|
||||
jsonStr := fmt.Sprintf(`{ "HeaderKey": %q }`, key)
|
||||
jsonStr := fmt.Sprintf(`{ "Key": %q }`, key)
|
||||
fmt.Println(jsonStr)
|
||||
|
||||
req, err := http.NewRequest("POST", httpserver.URL+"/"+"ctxtoctx", strings.NewReader(jsonStr))
|
||||
req, err := http.NewRequest("POST", httpAddr+"/"+"ctxtoctx", strings.NewReader(jsonStr))
|
||||
if err != nil {
|
||||
t.Fatal(errors.Wrap(err, "cannot construct http request"))
|
||||
}
|
||||
|
@ -288,7 +253,7 @@ type httpRequestBuilder struct {
|
|||
|
||||
func (h httpRequestBuilder) Test(t *testing.T) ([]byte, error) {
|
||||
t.Logf("Method: %q | Route: %q", h.method, h.route)
|
||||
httpReq, err := http.NewRequest(h.method, httpserver.URL+"/"+h.route, bytes.NewReader(h.body))
|
||||
httpReq, err := http.NewRequest(h.method, httpAddr+"/"+h.route, bytes.NewReader(h.body))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
// Go Kit
|
||||
"github.com/go-kit/kit/log"
|
||||
|
||||
pb "github.com/TuneLab/go-truss/truss/_integration-tests/transport/transport-service"
|
||||
svc "github.com/TuneLab/go-truss/truss/_integration-tests/transport/transport-service/generated"
|
||||
handler "github.com/TuneLab/go-truss/truss/_integration-tests/transport/transport-service/handlers/server"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
var logger log.Logger
|
||||
logger = log.NewNopLogger()
|
||||
|
||||
var service handler.Service
|
||||
{
|
||||
service = handler.NewService()
|
||||
}
|
||||
|
||||
// Endpoint domain.
|
||||
getWithQueryE := svc.MakeGetWithQueryEndpoint(service)
|
||||
getWithRepeatedQueryE := svc.MakeGetWithRepeatedQueryEndpoint(service)
|
||||
postWithNestedMessageBodyE := svc.MakePostWithNestedMessageBodyEndpoint(service)
|
||||
ctxToCtxE := svc.MakeCtxToCtxEndpoint(service)
|
||||
|
||||
endpoints := svc.Endpoints{
|
||||
GetWithQueryEndpoint: getWithQueryE,
|
||||
GetWithRepeatedQueryEndpoint: getWithRepeatedQueryE,
|
||||
PostWithNestedMessageBodyEndpoint: postWithNestedMessageBodyE,
|
||||
CtxToCtxEndpoint: ctxToCtxE,
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
// http test server
|
||||
h := svc.MakeHTTPHandler(ctx, endpoints, logger)
|
||||
httpTestServer := httptest.NewServer(h)
|
||||
|
||||
// grpc test server
|
||||
ln, err := net.Listen("tcp", "localhost:0")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
return
|
||||
}
|
||||
s := grpc.NewServer()
|
||||
gs := svc.MakeGRPCServer(ctx, endpoints)
|
||||
pb.RegisterTransportPermutationsServer(s, gs)
|
||||
go s.Serve(ln)
|
||||
|
||||
httpAddr = httpTestServer.URL
|
||||
grpcAddr = ":" + strconv.Itoa(ln.Addr().(*net.TCPAddr).Port)
|
||||
os.Exit(m.Run())
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package httptest;
|
||||
package transport;
|
||||
|
||||
import "google/api/annotations.proto";
|
||||
|
||||
service HTTPPermutations {
|
||||
service TransportPermutations {
|
||||
rpc GetWithQuery (GetWithQueryRequest) returns (GetWithQueryResponse) {
|
||||
option (google.api.http) = {
|
||||
get: "/getwithquery"
|
||||
|
@ -21,7 +21,7 @@ service HTTPPermutations {
|
|||
body: "*"
|
||||
};
|
||||
}
|
||||
rpc CtxToCtxViaHTTPHeader (HeaderRequest) returns (HeaderResponse){
|
||||
rpc CtxToCtx (MetaRequest) returns (MetaResponse){
|
||||
option (google.api.http) = {
|
||||
post: "/ctxtoctx"
|
||||
body: "*"
|
||||
|
@ -59,10 +59,10 @@ message PostWithNestedMessageBodyResponse {
|
|||
int64 V = 1;
|
||||
}
|
||||
|
||||
message HeaderRequest{
|
||||
string HeaderKey = 1;
|
||||
message MetaRequest{
|
||||
string Key = 1;
|
||||
}
|
||||
|
||||
message HeaderResponse {
|
||||
message MetaResponse {
|
||||
string V = 1;
|
||||
}
|
Загрузка…
Ссылка в новой задаче