Merge pull request #71 from hasLeland/plumbing-rewrite
New service definition implementation
This commit is contained in:
Коммит
854f30c888
|
@ -0,0 +1,129 @@
|
|||
package svcdef
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/TuneLab/go-truss/deftree/svcparse"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// consolidateHTTP accepts a SvcDef and the io.Readers for the proto files
|
||||
// comprising the definition. It modifies the SvcDef so that HTTPBindings and
|
||||
// their associated HTTPParamters are added to each ServiceMethod. After this,
|
||||
// each `HTTPBinding` will have a populated list of all the http parameters
|
||||
// that that binding requires, where that parameter should be located, and the
|
||||
// type of each parameter.
|
||||
func consolidateHTTP(sd *Svcdef, protoFiles []io.Reader) error {
|
||||
for _, pfile := range protoFiles {
|
||||
lex := svcparse.NewSvcLexer(pfile)
|
||||
protosvc, err := svcparse.ParseService(lex)
|
||||
if err != nil {
|
||||
if strings.Contains("'options' or", err.Error()) {
|
||||
log.Warnf("Parser found rpc method which lacks HTTP " +
|
||||
"annotations; this is allowed, but will result in HTTP " +
|
||||
"transport not being generated.")
|
||||
} else {
|
||||
return errors.Wrap(err, "error while parsing http options for the service definition")
|
||||
}
|
||||
}
|
||||
assembleHTTPParams(sd.Service, protosvc)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// assembleHTTPParams will use the output of the service parser to create
|
||||
// HTTPParams for each service RequestType field indicating that parameters
|
||||
// location, and the field to which it refers.
|
||||
func assembleHTTPParams(svc *Service, httpsvc *svcparse.Service) error {
|
||||
getMethNamed := func(name string) *ServiceMethod {
|
||||
for _, m := range svc.Methods {
|
||||
if m.Name == name {
|
||||
return m
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// This logic has been broken out of the for loop below to flatten
|
||||
// this function and avoid difficult to read nesting
|
||||
createParams := func(meth *ServiceMethod, parsedbind *svcparse.HTTPBinding) {
|
||||
msg := meth.RequestType.Message
|
||||
bind := HTTPBinding{}
|
||||
bind.Verb, bind.Path = getVerb(parsedbind)
|
||||
|
||||
params := make([]*HTTPParameter, 0)
|
||||
for _, field := range msg.Fields {
|
||||
new_param := &HTTPParameter{}
|
||||
new_param.Field = field
|
||||
new_param.Location = paramLocation(field, parsedbind)
|
||||
params = append(params, new_param)
|
||||
}
|
||||
bind.Params = params
|
||||
meth.Bindings = append(meth.Bindings, &bind)
|
||||
}
|
||||
|
||||
// Iterate through every HTTPBinding on every ServiceMethod, and create the
|
||||
// HTTPParameters for that HTTPBinding.
|
||||
for _, hm := range httpsvc.Methods {
|
||||
m := getMethNamed(hm.Name)
|
||||
if m == nil {
|
||||
return errors.New(fmt.Sprintf("Could not find service method named %q", hm.Name))
|
||||
}
|
||||
for _, hbind := range hm.HTTPBindings {
|
||||
createParams(m, hbind)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// getVerb returns the verb of a svcparse.HTTPBinding. If the binding does not
|
||||
// contain a field with a verb, returns two empty strings. Currently doesn't
|
||||
// support "custom" verbs.
|
||||
func getVerb(binding *svcparse.HTTPBinding) (verb string, path string) {
|
||||
for _, field := range binding.Fields {
|
||||
switch field.Kind {
|
||||
case "get", "put", "post", "delete", "patch":
|
||||
return field.Kind, field.Value
|
||||
}
|
||||
}
|
||||
return "", ""
|
||||
}
|
||||
|
||||
// paramLocation returns the location that a field would be found according to
|
||||
// the rules of a given HTTPBinding.
|
||||
func paramLocation(field *Field, binding *svcparse.HTTPBinding) string {
|
||||
path_params := getPathParams(binding)
|
||||
for _, path_param := range path_params {
|
||||
if strings.Split(path_param, ".")[0] == field.Name {
|
||||
return "path"
|
||||
}
|
||||
}
|
||||
for _, optField := range binding.Fields {
|
||||
if optField.Kind == "body" {
|
||||
if optField.Value == "*" {
|
||||
return "body"
|
||||
} else if optField.Value == field.Name {
|
||||
return "body"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "query"
|
||||
}
|
||||
|
||||
// Returns a slice of strings containing all parameters in the path
|
||||
func getPathParams(binding *svcparse.HTTPBinding) []string {
|
||||
_, path := getVerb(binding)
|
||||
find_params := regexp.MustCompile("{(.*?)}")
|
||||
remove_braces := regexp.MustCompile("{|}")
|
||||
params := find_params.FindAllString(path, -1)
|
||||
rv := []string{}
|
||||
for _, p := range params {
|
||||
rv = append(rv, remove_braces.ReplaceAllString(p, ""))
|
||||
}
|
||||
return rv
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
package svcdef
|
||||
|
||||
import (
|
||||
"io"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/TuneLab/go-truss/deftree/svcparse"
|
||||
)
|
||||
|
||||
func TestGetPathParams(t *testing.T) {
|
||||
binding := &svcparse.HTTPBinding{
|
||||
Fields: []*svcparse.Field{
|
||||
&svcparse.Field{
|
||||
Kind: "get",
|
||||
Value: `"/{a}/{b}"`,
|
||||
},
|
||||
},
|
||||
}
|
||||
params := getPathParams(binding)
|
||||
if len(params) != 2 {
|
||||
t.Fatalf("Params (%v) is length '%v', expected length 2", params, len(params))
|
||||
}
|
||||
expected := []string{"a", "b"}
|
||||
if !reflect.DeepEqual(params, expected) {
|
||||
t.Fatalf("Params is %v, expected %v", params, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHTTPParams(t *testing.T) {
|
||||
goCode := `
|
||||
package TEST
|
||||
|
||||
type EnumType int32
|
||||
|
||||
const (
|
||||
EnumType_A EnumType = 0
|
||||
EnumType_B EnumType = 1
|
||||
EnumType_C EnumType = 2
|
||||
)
|
||||
type MsgA struct {
|
||||
A int64
|
||||
}
|
||||
type Thing struct {
|
||||
A *MsgA
|
||||
AA []*MsgA
|
||||
C EnumType
|
||||
MapField map[string]*MsgA
|
||||
}
|
||||
|
||||
type MapServer interface {
|
||||
GetThing(context.Context, *Thing) (*Thing, error)
|
||||
}
|
||||
`
|
||||
protoCode := `
|
||||
syntax = "proto3";
|
||||
package TEST;
|
||||
import "google/api/annotations.proto";
|
||||
|
||||
enum EnumType {
|
||||
A = 0;
|
||||
B = 1;
|
||||
C = 2;
|
||||
}
|
||||
|
||||
message MsgA {
|
||||
int64 A = 1;
|
||||
}
|
||||
|
||||
message Thing {
|
||||
MsgA A = 1;
|
||||
repeated MsgA AA = 17;
|
||||
EnumType C = 18;
|
||||
map<string, MsgA> MapField = 19;
|
||||
}
|
||||
|
||||
service Map {
|
||||
rpc GetThing (Thing) returns (Thing) {
|
||||
option (google.api.http) = {
|
||||
get: "/1"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
}`
|
||||
// From code, build our SvcDef
|
||||
sd, err := New([]io.Reader{strings.NewReader(goCode)}, []io.Reader{strings.NewReader(protoCode)})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
tmap := newTypeMap(sd)
|
||||
|
||||
rq := sd.Service.Methods[0].RequestType
|
||||
bind := sd.Service.Methods[0].Bindings[0]
|
||||
if len(bind.Params) != len(tmap["Thing"].Message.Fields) {
|
||||
t.Fatalf(
|
||||
"Number of http parameters '%v' differs from number of fields on message '%v'",
|
||||
len(bind.Params), len(tmap["Thing"].Message.Fields))
|
||||
}
|
||||
|
||||
fieldWithName := func(name string) *Field {
|
||||
for _, f := range rq.Message.Fields {
|
||||
if f.Name == name {
|
||||
return f
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Verify that each HTTPParam corresponds to a single field on the RequestType
|
||||
for _, param := range bind.Params {
|
||||
parmName := param.Field.Name
|
||||
fld := fieldWithName(parmName)
|
||||
if fld == nil {
|
||||
t.Fatalf("HTTPParam with name %q does not have corresponding field on RequestType", parmName)
|
||||
}
|
||||
if fld != param.Field {
|
||||
t.Fatalf("Parameter %q does not refer to the same field as field %q", parmName, fld.Name)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package svcdef
|
||||
|
||||
// typeBox holds either a Message or an Enum; used only in resolveTypes() to
|
||||
// associate FieldTypes with their underlying data.
|
||||
type typeBox struct {
|
||||
Message *Message
|
||||
Enum *Enum
|
||||
}
|
||||
|
||||
// newTypeMap returns a map of type (Message/Enum) Names to correlated
|
||||
// typeBoxes
|
||||
func newTypeMap(sd *Svcdef) map[string]typeBox {
|
||||
rv := make(map[string]typeBox)
|
||||
for _, m := range sd.Messages {
|
||||
rv[m.Name] = typeBox{Message: m}
|
||||
}
|
||||
for _, e := range sd.Enums {
|
||||
rv[e.Name] = typeBox{Enum: e}
|
||||
}
|
||||
return rv
|
||||
}
|
||||
|
||||
// resolveTypes sets the underlying types for all of our service methods
|
||||
// Fields, RequestTypes, and ResponseTypes. Since Enums have no Fields which
|
||||
// may refer to other types, they are ignored by resolveTypes.
|
||||
func resolveTypes(sd *Svcdef) {
|
||||
tmap := newTypeMap(sd)
|
||||
for _, m := range sd.Messages {
|
||||
for _, f := range m.Fields {
|
||||
setType(f.Type, tmap)
|
||||
}
|
||||
}
|
||||
if sd.Service != nil {
|
||||
for _, m := range sd.Service.Methods {
|
||||
setType(m.RequestType, tmap)
|
||||
setType(m.ResponseType, tmap)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// setType unpacks typeBox value into corresponding FieldType
|
||||
func setType(f *FieldType, tmap map[string]typeBox) {
|
||||
// Special case maps with valuetypes pointing to messages
|
||||
if f.Map != nil {
|
||||
if f.Map.ValueType.StarExpr {
|
||||
f = f.Map.ValueType
|
||||
}
|
||||
}
|
||||
entry, ok := tmap[f.Name]
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
switch {
|
||||
case entry.Enum != nil:
|
||||
f.Enum = entry.Enum
|
||||
case entry.Message != nil:
|
||||
f.Message = entry.Message
|
||||
}
|
||||
}
|
|
@ -0,0 +1,375 @@
|
|||
/*
|
||||
Package svcdef provides a straightforward view of the Go code for a gRPC
|
||||
service defined using protocol buffers. Information is distilled from the
|
||||
.proto files comprising the definition, as well as the Go source files
|
||||
generated from those same .proto files.
|
||||
|
||||
Since svcdef is only meant to be used to generate Go code, svcdef has a limited
|
||||
view of the definition of the gRPC service.
|
||||
|
||||
Additionally, since svcdef only parses Go code generated by protoc-gen-go, all
|
||||
methods accept only ast types with structures created by protoc-gen-go. See
|
||||
NewTYPE functions such as NewMap for details on the relevant conventions.
|
||||
|
||||
Note that svcdef does not support embedding sub-fields of nested messages into
|
||||
the path of an HTTP annotation.
|
||||
*/
|
||||
package svcdef
|
||||
|
||||
import (
|
||||
"go/ast"
|
||||
"go/parser"
|
||||
"go/token"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// Svcdef is the top-level struct for the definition of a service.
|
||||
type Svcdef struct {
|
||||
// PkgName will be the pacakge name of the go file(s) analyzed. So if a
|
||||
// Go file contained "package authz", then PkgName will be "authz". If
|
||||
// multiple Go files are analyzed, it will be the package name of the last
|
||||
// go file analyzed.
|
||||
PkgName string
|
||||
Messages []*Message
|
||||
Enums []*Enum
|
||||
// Service contains the sole service for this Svcdef
|
||||
Service *Service
|
||||
}
|
||||
|
||||
// Message represents a protobuf Message, though greatly simplified.
|
||||
type Message struct {
|
||||
Name string
|
||||
Fields []*Field
|
||||
}
|
||||
|
||||
type Enum struct {
|
||||
Name string
|
||||
}
|
||||
|
||||
type Map struct {
|
||||
// KeyType will always be a basetype, e.g. string, int64, etc.
|
||||
KeyType *FieldType
|
||||
ValueType *FieldType
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
Name string
|
||||
Methods []*ServiceMethod
|
||||
}
|
||||
|
||||
type ServiceMethod struct {
|
||||
Name string
|
||||
RequestType *FieldType
|
||||
ResponseType *FieldType
|
||||
// Bindings contains information for mapping http paths and paramters onto
|
||||
// the fields of this ServiceMethods RequestType.
|
||||
Bindings []*HTTPBinding
|
||||
}
|
||||
|
||||
// Field represents a field on a protobuf message.
|
||||
type Field struct {
|
||||
Name string
|
||||
Type *FieldType
|
||||
}
|
||||
|
||||
// FieldType contains information about the type of one Field on a message,
|
||||
// such as if that Field is a slice or if it's a pointer, as well as a
|
||||
// reference to the definition of the type of this Field.
|
||||
type FieldType struct {
|
||||
// Name will contain the name of the type, for example "string" or "bool"
|
||||
Name string
|
||||
// Enum contains a pointer to the Enum type this fieldtype represents, if
|
||||
// this FieldType represents an Enum. If not, Enum is nil.
|
||||
Enum *Enum
|
||||
// Message contains a pointer to the Message type this FieldType
|
||||
// represents, if this FieldType represents a Message. If not, Message is
|
||||
// nil.
|
||||
Message *Message
|
||||
// Map contains a pointer to the Map type this FieldType represents, if
|
||||
// this FieldType represents a Map. If not, Map is nil.
|
||||
Map *Map
|
||||
// StarExpr is True if this FieldType represents a pointer to a type.
|
||||
StarExpr bool
|
||||
// ArrayType is True if this FieldType represents a slice of a type.
|
||||
ArrayType bool
|
||||
}
|
||||
|
||||
// HTTPBinding represents one of potentially several bindings from a gRPC
|
||||
// service method to a particuar HTTP path/verb.
|
||||
type HTTPBinding struct {
|
||||
Verb string
|
||||
Path string
|
||||
// There is one HTTPParamter for each of the fields on parent service
|
||||
// methods RequestType.
|
||||
Params []*HTTPParameter
|
||||
}
|
||||
|
||||
// HTTPParameter represents the location of one field for a given HTTPBinding.
|
||||
// Each HTTPParameter corresponds to one Field of the parent
|
||||
// ServiceMethod.RequestType.Fields
|
||||
type HTTPParameter struct {
|
||||
// Field points to a Field on the Parent service methods "RequestType".
|
||||
Field *Field
|
||||
// Location will be either "body", "path", or "query"
|
||||
Location string
|
||||
}
|
||||
|
||||
func retrieveTypeSpecs(f *ast.File) ([]*ast.TypeSpec, error) {
|
||||
var rv []*ast.TypeSpec
|
||||
for _, dec := range f.Decls {
|
||||
switch gendec := dec.(type) {
|
||||
case *ast.GenDecl:
|
||||
for _, spec := range gendec.Specs {
|
||||
switch ts := spec.(type) {
|
||||
case *ast.TypeSpec:
|
||||
rv = append(rv, ts)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return rv, nil
|
||||
}
|
||||
|
||||
// New creates a Svcdef by parsing the provided Go and Protobuf source files to
|
||||
// derive type information, gRPC service data, and HTTP annotations.
|
||||
func New(goFiles []io.Reader, protoFiles []io.Reader) (*Svcdef, error) {
|
||||
rv := Svcdef{}
|
||||
|
||||
for _, gofile := range goFiles {
|
||||
fset := token.NewFileSet()
|
||||
fileAst, err := parser.ParseFile(fset, "", gofile, parser.ParseComments)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "couldn't parse go file to create Svcdef")
|
||||
}
|
||||
|
||||
typespecs, _ := retrieveTypeSpecs(fileAst)
|
||||
for _, t := range typespecs {
|
||||
switch typdf := t.Type.(type) {
|
||||
case *ast.Ident:
|
||||
if typdf.Name == "int32" {
|
||||
nenm, err := NewEnum(t)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "error parsing enum %q", t.Name.Name)
|
||||
}
|
||||
rv.Enums = append(rv.Enums, nenm)
|
||||
}
|
||||
case *ast.StructType:
|
||||
nmsg, err := NewMessage(t)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "error parsing message %q", t.Name.Name)
|
||||
}
|
||||
rv.Messages = append(rv.Messages, nmsg)
|
||||
case *ast.InterfaceType:
|
||||
// Each service will have two interfaces ("{SVCNAME}Server" and
|
||||
// "{SVCNAME}Client") each containing the same information that we
|
||||
// care about, but structured a bit differently. For simplicity,
|
||||
// skip the "Client" interface.
|
||||
if strings.HasSuffix("Client", t.Name.Name) {
|
||||
break
|
||||
}
|
||||
nsvc, err := NewService(t)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "error parsing service %q", t.Name.Name)
|
||||
}
|
||||
rv.Service = nsvc
|
||||
}
|
||||
}
|
||||
}
|
||||
resolveTypes(&rv)
|
||||
err := consolidateHTTP(&rv, protoFiles)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to consolidate HTTP")
|
||||
}
|
||||
|
||||
return &rv, nil
|
||||
}
|
||||
|
||||
func NewEnum(e *ast.TypeSpec) (*Enum, error) {
|
||||
return &Enum{
|
||||
Name: e.Name.Name,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// NewMessage returns a new Message struct derived from an *ast.TypeSpec with a
|
||||
// Type of *ast.StructType.
|
||||
func NewMessage(m *ast.TypeSpec) (*Message, error) {
|
||||
rv := &Message{
|
||||
Name: m.Name.Name,
|
||||
}
|
||||
|
||||
strct := m.Type.(*ast.StructType)
|
||||
for _, f := range strct.Fields.List {
|
||||
nfield, err := NewField(f)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "couldn't create field %q while creating message %q", f.Names[0].Name, rv.Name)
|
||||
}
|
||||
rv.Fields = append(rv.Fields, nfield)
|
||||
}
|
||||
|
||||
return rv, nil
|
||||
}
|
||||
|
||||
// NewMap returns a new Map struct derived from an ast.Expr interface
|
||||
// implemented by an *ast.MapType struct. This code cannot accept an arbitrary
|
||||
// MapType, only one which follows the conventions of Go code generated by
|
||||
// protoc-gen-go. Those conventions are:
|
||||
//
|
||||
// 1. The KeyType of the *ast.MapType will always be an ast.Ident
|
||||
// 2. The ValueType may be an ast.Ident OR an ast.StarExpr -> ast.Ident
|
||||
//
|
||||
// These rules are a result of the rules for map fields of Protobuf messages,
|
||||
// namely that a key may only be represented by a non-float basetype (e.g.
|
||||
// int64, string, etc.), and that a value may be either a basetype or a Message
|
||||
// type or an Enum type. In the resulting Go code, a basetype will be
|
||||
// represented as an ast.Ident, while a key that is a Message or Enum type will
|
||||
// be represented as an *ast.StarExpr which references an ast.Ident.
|
||||
func NewMap(m ast.Expr) (*Map, error) {
|
||||
rv := &Map{
|
||||
KeyType: &FieldType{},
|
||||
ValueType: &FieldType{},
|
||||
}
|
||||
mp := m.(*ast.MapType)
|
||||
// KeyType will always be an ast.Ident, ValueType may be an ast.Ident or an
|
||||
// ast.StarExpr->ast.Ident
|
||||
key := mp.Key.(*ast.Ident)
|
||||
rv.KeyType.Name = key.Name
|
||||
var keyFollower func(ast.Expr)
|
||||
keyFollower = func(e ast.Expr) {
|
||||
switch ex := e.(type) {
|
||||
case *ast.Ident:
|
||||
rv.ValueType.Name = ex.Name
|
||||
case *ast.StarExpr:
|
||||
rv.ValueType.StarExpr = true
|
||||
keyFollower(ex.X)
|
||||
}
|
||||
}
|
||||
keyFollower(mp.Value)
|
||||
|
||||
return rv, nil
|
||||
}
|
||||
|
||||
// NewService returns a new Service struct derived from an *ast.TypeSpec with a
|
||||
// Type of *ast.InterfaceType representing an "{SVCNAME}Client" interface.
|
||||
func NewService(s *ast.TypeSpec) (*Service, error) {
|
||||
rv := &Service{
|
||||
Name: s.Name.Name,
|
||||
}
|
||||
asvc := s.Type.(*ast.InterfaceType)
|
||||
for _, m := range asvc.Methods.List {
|
||||
nmeth, err := NewServiceMethod(m)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "Couldn't create service method %q of service %q", m.Names[0].Name, rv.Name)
|
||||
}
|
||||
rv.Methods = append(rv.Methods, nmeth)
|
||||
}
|
||||
return rv, nil
|
||||
}
|
||||
|
||||
// NewServiceMethod returns a new ServiceMethod derived from a method of a
|
||||
// Service interface. This is accepted in the form of an *ast.Field which
|
||||
// contains the name of the method.
|
||||
func NewServiceMethod(m *ast.Field) (*ServiceMethod, error) {
|
||||
rv := &ServiceMethod{
|
||||
Name: m.Names[0].Name,
|
||||
}
|
||||
ft, ok := m.Type.(*ast.FuncType)
|
||||
if !ok {
|
||||
return nil, errors.New("Provided *ast.Field.Type is not of type *ast.FuncType; cannot proceed")
|
||||
}
|
||||
|
||||
input := ft.Params.List
|
||||
output := ft.Results.List
|
||||
|
||||
// Zero'th param of a serverMethod is Context.context, while first param is
|
||||
// this methods RequestType. Example:
|
||||
//
|
||||
// GetMap(context.Context, *MapTypeRequest) (*MapTypeResponse, error)
|
||||
// └────────────┘ └─────────────┘
|
||||
// RequestType ResponseType
|
||||
// └──────────────────────────────┘ └─────────────────────┘
|
||||
// input output
|
||||
|
||||
rq := input[1]
|
||||
rs := output[0]
|
||||
|
||||
makeFieldType := func(in *ast.Field) (*FieldType, error) {
|
||||
star, ok := in.Type.(*ast.StarExpr)
|
||||
if !ok {
|
||||
return nil, errors.New("could not create FieldType, in.Type is not *ast.StarExpr")
|
||||
}
|
||||
ident, ok := star.X.(*ast.Ident)
|
||||
if !ok {
|
||||
return nil, errors.New("could not create FieldType, star.Type is not *ast.Ident")
|
||||
}
|
||||
return &FieldType{
|
||||
Name: ident.Name,
|
||||
StarExpr: true,
|
||||
}, nil
|
||||
}
|
||||
|
||||
var err error
|
||||
rv.RequestType, err = makeFieldType(rq)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "RequestType creation of service method %q failed", rv.Name)
|
||||
}
|
||||
rv.ResponseType, err = makeFieldType(rs)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "ResponseType creation of service method %q failed", rv.Name)
|
||||
}
|
||||
|
||||
return rv, nil
|
||||
}
|
||||
|
||||
// NewField returns a Field struct with information distilled from an
|
||||
// *ast.Field. If the provided *ast.Field does not match the conventions of
|
||||
// code generated by protoc-gen-go, an error will be returned.
|
||||
func NewField(f *ast.Field) (*Field, error) {
|
||||
// The following is an informational table of how the proto-to-go
|
||||
// concepts map to the Types of an ast.Field. An arrow indicates "nested
|
||||
// within". This is here as an implementors aid.
|
||||
//
|
||||
// | Type Genres | Repeated | Naked |
|
||||
// |-------------|------------------------|---------------|
|
||||
// | Enum | Array -> Ident | Ident |
|
||||
// | Message | Array -> Star -> Ident | Star -> Ident |
|
||||
// | BaseType | Array -> Ident | Ident |
|
||||
//
|
||||
// Map types will always have a KeyType which is ident, and a value that is one of
|
||||
// the Type Genres specified in the table above.
|
||||
rv := &Field{
|
||||
Name: f.Names[0].Name,
|
||||
Type: &FieldType{},
|
||||
}
|
||||
|
||||
// TypeFollower 'follows' the type of the provided ast.Field, determining
|
||||
// the name of this fields type and if it's a StarExpr, an ArrayType, or
|
||||
// both, and modifying the return value accordingly.
|
||||
var typeFollower func(ast.Expr) error
|
||||
typeFollower = func(e ast.Expr) error {
|
||||
switch ex := e.(type) {
|
||||
case *ast.Ident:
|
||||
rv.Type.Name = ex.Name
|
||||
case *ast.StarExpr:
|
||||
rv.Type.StarExpr = true
|
||||
typeFollower(ex.X)
|
||||
case *ast.ArrayType:
|
||||
rv.Type.ArrayType = true
|
||||
typeFollower(ex.Elt)
|
||||
case *ast.MapType:
|
||||
mp, err := NewMap(ex)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to create map for field %q", rv.Name)
|
||||
}
|
||||
rv.Type.Map = mp
|
||||
}
|
||||
return nil
|
||||
}
|
||||
err := typeFollower(f.Type)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rv, nil
|
||||
}
|
|
@ -0,0 +1,143 @@
|
|||
package svcdef
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSvcdef(t *testing.T) {
|
||||
gf, err := os.Open("./test-go.txt")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
pf, err := os.Open("./test-proto.txt")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
sd, err := New([]io.Reader{gf}, []io.Reader{pf})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if sd == nil {
|
||||
t.Fatal("returned SvcDef is nil!")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func TestTypeResolution(t *testing.T) {
|
||||
caseCode := `
|
||||
package TEST
|
||||
type EnumType int32
|
||||
|
||||
type NestedMessageA struct {
|
||||
A *NestedMessageC
|
||||
}
|
||||
type NestedMessageB struct {
|
||||
A []*NestedMessageC
|
||||
}
|
||||
type NestedMessageC struct {
|
||||
A int64
|
||||
}
|
||||
|
||||
type NestedTypeRequest struct {
|
||||
A *NestedMessageA
|
||||
B []*NestedMessageB
|
||||
C EnumType
|
||||
}`
|
||||
sd, err := New([]io.Reader{strings.NewReader(caseCode)}, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tmap := newTypeMap(sd)
|
||||
|
||||
var cases = []struct {
|
||||
name, fieldname, typename string
|
||||
}{
|
||||
{"NestedMessageA", "A", "NestedMessageC"},
|
||||
{"NestedMessageB", "A", "NestedMessageC"},
|
||||
{"NestedTypeRequest", "A", "NestedMessageA"},
|
||||
{"NestedTypeRequest", "B", "NestedMessageB"},
|
||||
{"NestedTypeRequest", "C", "EnumType"},
|
||||
}
|
||||
for _, c := range cases {
|
||||
box, ok := tmap[c.name]
|
||||
if !ok {
|
||||
t.Errorf("Could not find %q in map of types", c.name)
|
||||
}
|
||||
msg := box.Message
|
||||
if msg.Name != c.name {
|
||||
t.Errorf("Message in typemap is named %q, wanted %q", msg.Name, c.name)
|
||||
}
|
||||
var selectedf *Field
|
||||
foundfield := false
|
||||
for _, f := range msg.Fields {
|
||||
if f.Name == c.fieldname {
|
||||
foundfield = true
|
||||
selectedf = f
|
||||
}
|
||||
}
|
||||
if !foundfield {
|
||||
t.Fatalf("Could't find field %q in message %q", c.fieldname, msg.Name)
|
||||
}
|
||||
|
||||
ftypebox, ok := tmap[selectedf.Type.Name]
|
||||
if !ok {
|
||||
t.Errorf("Field %q has type %q which is not found in the typemap", selectedf.Name, selectedf.Type.Name)
|
||||
}
|
||||
if selectedf.Type.Enum != nil {
|
||||
ftype := ftypebox.Enum
|
||||
if selectedf.Type.Enum != ftype {
|
||||
t.Errorf("Field %q on message %q has type which differs from the typemap type of the same name, got %p, want %p", selectedf.Name, msg.Name, selectedf.Type, ftype)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Test that after calling New(), type resolution of map values functions
|
||||
// correctly. So if a message has a map field, and that map field has values
|
||||
// that are some other message type, then the type of the key will be correct.
|
||||
func TestNewMapTypeResolution(t *testing.T) {
|
||||
caseCode := `
|
||||
package TEST
|
||||
|
||||
type NestedMessageC struct {
|
||||
A int64
|
||||
}
|
||||
type MsgWithMap struct {
|
||||
Beta map[int64]*NestedMessageC
|
||||
}
|
||||
`
|
||||
sd, err := New([]io.Reader{strings.NewReader(caseCode)}, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// findMsg defined here for brevity
|
||||
findMsg := func(name string) *Message {
|
||||
for _, m := range sd.Messages {
|
||||
if m.Name == name {
|
||||
return m
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
msg := findMsg("MsgWithMap")
|
||||
if msg == nil {
|
||||
t.Fatal("Couldn't find message 'MsgWithMap'")
|
||||
}
|
||||
expected := findMsg("NestedMessageC")
|
||||
if expected == nil {
|
||||
t.Fatal("Couldn't find message 'NestedMessageC'")
|
||||
}
|
||||
|
||||
beta := msg.Fields[0].Type.Map
|
||||
|
||||
if beta.ValueType.Message != expected {
|
||||
t.Fatalf("Expected beta ValueType to be 'NestedMessageC', is %q", beta.ValueType.Message.Name)
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,973 @@
|
|||
// Code generated by protoc-gen-go.
|
||||
// source: svc.proto
|
||||
// DO NOT EDIT!
|
||||
|
||||
/*
|
||||
Package TEST is a generated protocol buffer package.
|
||||
|
||||
It is generated from these files:
|
||||
svc.proto
|
||||
|
||||
It has these top-level messages:
|
||||
NestedTypeRequest
|
||||
NestedMessageA
|
||||
NestedMessageB
|
||||
NestedMessageC
|
||||
NestedTypeResponse
|
||||
MapTypeRequest
|
||||
NestedMapMessageA
|
||||
NestedMapMessageB
|
||||
NestedMapMessageC
|
||||
MapTypeResponse
|
||||
MapNestedMsg
|
||||
RepeatedTypes
|
||||
*/
|
||||
package TEST
|
||||
|
||||
import proto "github.com/golang/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
import _ "github.com/TuneLab/go-truss/pbinfo/scrap/third_party/googleapis/google/api"
|
||||
|
||||
import (
|
||||
context "golang.org/x/net/context"
|
||||
grpc "google.golang.org/grpc"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
|
||||
|
||||
type EnumType int32
|
||||
|
||||
const (
|
||||
EnumType_A EnumType = 0
|
||||
EnumType_B EnumType = 1
|
||||
EnumType_C EnumType = 2
|
||||
)
|
||||
|
||||
var EnumType_name = map[int32]string{
|
||||
0: "A",
|
||||
1: "B",
|
||||
2: "C",
|
||||
}
|
||||
var EnumType_value = map[string]int32{
|
||||
"A": 0,
|
||||
"B": 1,
|
||||
"C": 2,
|
||||
}
|
||||
|
||||
func (x EnumType) String() string {
|
||||
return proto.EnumName(EnumType_name, int32(x))
|
||||
}
|
||||
func (EnumType) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
|
||||
|
||||
type NestedTypeRequest struct {
|
||||
A *NestedMessageA `protobuf:"bytes,1,opt,name=A" json:"A,omitempty"`
|
||||
B []*NestedMessageB `protobuf:"bytes,17,rep,name=B" json:"B,omitempty"`
|
||||
C EnumType `protobuf:"varint,18,opt,name=C,enum=TEST.EnumType" json:"C,omitempty"`
|
||||
}
|
||||
|
||||
func (m *NestedTypeRequest) Reset() { *m = NestedTypeRequest{} }
|
||||
func (m *NestedTypeRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*NestedTypeRequest) ProtoMessage() {}
|
||||
func (*NestedTypeRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
|
||||
|
||||
func (m *NestedTypeRequest) GetA() *NestedMessageA {
|
||||
if m != nil {
|
||||
return m.A
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *NestedTypeRequest) GetB() []*NestedMessageB {
|
||||
if m != nil {
|
||||
return m.B
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type NestedMessageA struct {
|
||||
A *NestedMessageC `protobuf:"bytes,1,opt,name=A" json:"A,omitempty"`
|
||||
}
|
||||
|
||||
func (m *NestedMessageA) Reset() { *m = NestedMessageA{} }
|
||||
func (m *NestedMessageA) String() string { return proto.CompactTextString(m) }
|
||||
func (*NestedMessageA) ProtoMessage() {}
|
||||
func (*NestedMessageA) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
|
||||
|
||||
func (m *NestedMessageA) GetA() *NestedMessageC {
|
||||
if m != nil {
|
||||
return m.A
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type NestedMessageB struct {
|
||||
A []*NestedMessageC `protobuf:"bytes,1,rep,name=A" json:"A,omitempty"`
|
||||
}
|
||||
|
||||
func (m *NestedMessageB) Reset() { *m = NestedMessageB{} }
|
||||
func (m *NestedMessageB) String() string { return proto.CompactTextString(m) }
|
||||
func (*NestedMessageB) ProtoMessage() {}
|
||||
func (*NestedMessageB) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
|
||||
|
||||
func (m *NestedMessageB) GetA() []*NestedMessageC {
|
||||
if m != nil {
|
||||
return m.A
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type NestedMessageC struct {
|
||||
A int64 `protobuf:"varint,1,opt,name=A" json:"A,omitempty"`
|
||||
}
|
||||
|
||||
func (m *NestedMessageC) Reset() { *m = NestedMessageC{} }
|
||||
func (m *NestedMessageC) String() string { return proto.CompactTextString(m) }
|
||||
func (*NestedMessageC) ProtoMessage() {}
|
||||
func (*NestedMessageC) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }
|
||||
|
||||
type NestedTypeResponse struct {
|
||||
A *NestedMessageA `protobuf:"bytes,16,opt,name=A" json:"A,omitempty"`
|
||||
B []*NestedMessageB `protobuf:"bytes,17,rep,name=B" json:"B,omitempty"`
|
||||
C EnumType `protobuf:"varint,18,opt,name=C,enum=TEST.EnumType" json:"C,omitempty"`
|
||||
}
|
||||
|
||||
func (m *NestedTypeResponse) Reset() { *m = NestedTypeResponse{} }
|
||||
func (m *NestedTypeResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*NestedTypeResponse) ProtoMessage() {}
|
||||
func (*NestedTypeResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} }
|
||||
|
||||
func (m *NestedTypeResponse) GetA() *NestedMessageA {
|
||||
if m != nil {
|
||||
return m.A
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *NestedTypeResponse) GetB() []*NestedMessageB {
|
||||
if m != nil {
|
||||
return m.B
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type MapTypeRequest struct {
|
||||
A *NestedMapMessageA `protobuf:"bytes,1,opt,name=A" json:"A,omitempty"`
|
||||
B []*NestedMapMessageB `protobuf:"bytes,2,rep,name=B" json:"B,omitempty"`
|
||||
AA map[string]float64 `protobuf:"bytes,11,rep,name=AA" json:"AA,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"fixed64,2,opt,name=value"`
|
||||
BB map[string]float32 `protobuf:"bytes,12,rep,name=BB" json:"BB,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"fixed32,2,opt,name=value"`
|
||||
CC map[string]int32 `protobuf:"bytes,13,rep,name=CC" json:"CC,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"`
|
||||
DD map[string]int64 `protobuf:"bytes,14,rep,name=DD" json:"DD,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"`
|
||||
EE map[string]uint32 `protobuf:"bytes,15,rep,name=EE" json:"EE,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"`
|
||||
FF map[string]uint64 `protobuf:"bytes,16,rep,name=FF" json:"FF,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"`
|
||||
GG map[string]int32 `protobuf:"bytes,17,rep,name=GG" json:"GG,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"zigzag32,2,opt,name=value"`
|
||||
HH map[string]int64 `protobuf:"bytes,18,rep,name=HH" json:"HH,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"zigzag64,2,opt,name=value"`
|
||||
II map[string]uint32 `protobuf:"bytes,19,rep,name=II" json:"II,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"fixed32,2,opt,name=value"`
|
||||
JJ map[string]uint64 `protobuf:"bytes,20,rep,name=JJ" json:"JJ,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"fixed64,2,opt,name=value"`
|
||||
KK map[string]int32 `protobuf:"bytes,21,rep,name=KK" json:"KK,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"fixed32,2,opt,name=value"`
|
||||
LL map[string]bool `protobuf:"bytes,22,rep,name=LL" json:"LL,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"`
|
||||
MM map[string]string `protobuf:"bytes,23,rep,name=MM" json:"MM,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
|
||||
AAA map[int64]float64 `protobuf:"bytes,31,rep,name=AAA" json:"AAA,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"fixed64,2,opt,name=value"`
|
||||
BBB map[int64]float32 `protobuf:"bytes,32,rep,name=BBB" json:"BBB,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"fixed32,2,opt,name=value"`
|
||||
CCC map[int64]int32 `protobuf:"bytes,33,rep,name=CCC" json:"CCC,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"`
|
||||
DDD map[int64]int64 `protobuf:"bytes,34,rep,name=DDD" json:"DDD,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"`
|
||||
EEE map[int64]uint32 `protobuf:"bytes,35,rep,name=EEE" json:"EEE,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"`
|
||||
FFF map[int64]uint64 `protobuf:"bytes,36,rep,name=FFF" json:"FFF,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"`
|
||||
GGG map[int64]int32 `protobuf:"bytes,37,rep,name=GGG" json:"GGG,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"zigzag32,2,opt,name=value"`
|
||||
HHH map[int64]int64 `protobuf:"bytes,38,rep,name=HHH" json:"HHH,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"zigzag64,2,opt,name=value"`
|
||||
III map[int64]uint32 `protobuf:"bytes,39,rep,name=III" json:"III,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"fixed32,2,opt,name=value"`
|
||||
JJJ map[int64]uint64 `protobuf:"bytes,40,rep,name=JJJ" json:"JJJ,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"fixed64,2,opt,name=value"`
|
||||
KKK map[int64]int32 `protobuf:"bytes,41,rep,name=KKK" json:"KKK,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"fixed32,2,opt,name=value"`
|
||||
LLL map[int64]bool `protobuf:"bytes,42,rep,name=LLL" json:"LLL,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"`
|
||||
MMM map[int64]string `protobuf:"bytes,43,rep,name=MMM" json:"MMM,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
|
||||
}
|
||||
|
||||
func (m *MapTypeRequest) Reset() { *m = MapTypeRequest{} }
|
||||
func (m *MapTypeRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*MapTypeRequest) ProtoMessage() {}
|
||||
func (*MapTypeRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} }
|
||||
|
||||
func (m *MapTypeRequest) GetA() *NestedMapMessageA {
|
||||
if m != nil {
|
||||
return m.A
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeRequest) GetB() []*NestedMapMessageB {
|
||||
if m != nil {
|
||||
return m.B
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeRequest) GetAA() map[string]float64 {
|
||||
if m != nil {
|
||||
return m.AA
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeRequest) GetBB() map[string]float32 {
|
||||
if m != nil {
|
||||
return m.BB
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeRequest) GetCC() map[string]int32 {
|
||||
if m != nil {
|
||||
return m.CC
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeRequest) GetDD() map[string]int64 {
|
||||
if m != nil {
|
||||
return m.DD
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeRequest) GetEE() map[string]uint32 {
|
||||
if m != nil {
|
||||
return m.EE
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeRequest) GetFF() map[string]uint64 {
|
||||
if m != nil {
|
||||
return m.FF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeRequest) GetGG() map[string]int32 {
|
||||
if m != nil {
|
||||
return m.GG
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeRequest) GetHH() map[string]int64 {
|
||||
if m != nil {
|
||||
return m.HH
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeRequest) GetII() map[string]uint32 {
|
||||
if m != nil {
|
||||
return m.II
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeRequest) GetJJ() map[string]uint64 {
|
||||
if m != nil {
|
||||
return m.JJ
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeRequest) GetKK() map[string]int32 {
|
||||
if m != nil {
|
||||
return m.KK
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeRequest) GetLL() map[string]bool {
|
||||
if m != nil {
|
||||
return m.LL
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeRequest) GetMM() map[string]string {
|
||||
if m != nil {
|
||||
return m.MM
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeRequest) GetAAA() map[int64]float64 {
|
||||
if m != nil {
|
||||
return m.AAA
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeRequest) GetBBB() map[int64]float32 {
|
||||
if m != nil {
|
||||
return m.BBB
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeRequest) GetCCC() map[int64]int32 {
|
||||
if m != nil {
|
||||
return m.CCC
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeRequest) GetDDD() map[int64]int64 {
|
||||
if m != nil {
|
||||
return m.DDD
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeRequest) GetEEE() map[int64]uint32 {
|
||||
if m != nil {
|
||||
return m.EEE
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeRequest) GetFFF() map[int64]uint64 {
|
||||
if m != nil {
|
||||
return m.FFF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeRequest) GetGGG() map[int64]int32 {
|
||||
if m != nil {
|
||||
return m.GGG
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeRequest) GetHHH() map[int64]int64 {
|
||||
if m != nil {
|
||||
return m.HHH
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeRequest) GetIII() map[int64]uint32 {
|
||||
if m != nil {
|
||||
return m.III
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeRequest) GetJJJ() map[int64]uint64 {
|
||||
if m != nil {
|
||||
return m.JJJ
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeRequest) GetKKK() map[int64]int32 {
|
||||
if m != nil {
|
||||
return m.KKK
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeRequest) GetLLL() map[int64]bool {
|
||||
if m != nil {
|
||||
return m.LLL
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeRequest) GetMMM() map[int64]string {
|
||||
if m != nil {
|
||||
return m.MMM
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type NestedMapMessageA struct {
|
||||
A *NestedMapMessageC `protobuf:"bytes,1,opt,name=A" json:"A,omitempty"`
|
||||
}
|
||||
|
||||
func (m *NestedMapMessageA) Reset() { *m = NestedMapMessageA{} }
|
||||
func (m *NestedMapMessageA) String() string { return proto.CompactTextString(m) }
|
||||
func (*NestedMapMessageA) ProtoMessage() {}
|
||||
func (*NestedMapMessageA) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{6} }
|
||||
|
||||
func (m *NestedMapMessageA) GetA() *NestedMapMessageC {
|
||||
if m != nil {
|
||||
return m.A
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type NestedMapMessageB struct {
|
||||
A []*NestedMapMessageC `protobuf:"bytes,1,rep,name=A" json:"A,omitempty"`
|
||||
}
|
||||
|
||||
func (m *NestedMapMessageB) Reset() { *m = NestedMapMessageB{} }
|
||||
func (m *NestedMapMessageB) String() string { return proto.CompactTextString(m) }
|
||||
func (*NestedMapMessageB) ProtoMessage() {}
|
||||
func (*NestedMapMessageB) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7} }
|
||||
|
||||
func (m *NestedMapMessageB) GetA() []*NestedMapMessageC {
|
||||
if m != nil {
|
||||
return m.A
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type NestedMapMessageC struct {
|
||||
A map[string]string `protobuf:"bytes,1,rep,name=A" json:"A,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
|
||||
}
|
||||
|
||||
func (m *NestedMapMessageC) Reset() { *m = NestedMapMessageC{} }
|
||||
func (m *NestedMapMessageC) String() string { return proto.CompactTextString(m) }
|
||||
func (*NestedMapMessageC) ProtoMessage() {}
|
||||
func (*NestedMapMessageC) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{8} }
|
||||
|
||||
func (m *NestedMapMessageC) GetA() map[string]string {
|
||||
if m != nil {
|
||||
return m.A
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type MapTypeResponse struct {
|
||||
A *NestedMapMessageA `protobuf:"bytes,1,opt,name=A" json:"A,omitempty"`
|
||||
B []*NestedMapMessageB `protobuf:"bytes,2,rep,name=B" json:"B,omitempty"`
|
||||
AA map[string]float64 `protobuf:"bytes,11,rep,name=AA" json:"AA,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"fixed64,2,opt,name=value"`
|
||||
BB map[string]float32 `protobuf:"bytes,12,rep,name=BB" json:"BB,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"fixed32,2,opt,name=value"`
|
||||
CC map[string]int32 `protobuf:"bytes,13,rep,name=CC" json:"CC,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"`
|
||||
DD map[string]int64 `protobuf:"bytes,14,rep,name=DD" json:"DD,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"`
|
||||
EE map[string]uint32 `protobuf:"bytes,15,rep,name=EE" json:"EE,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"`
|
||||
FF map[string]uint64 `protobuf:"bytes,16,rep,name=FF" json:"FF,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"`
|
||||
GG map[string]int32 `protobuf:"bytes,17,rep,name=GG" json:"GG,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"zigzag32,2,opt,name=value"`
|
||||
HH map[string]int64 `protobuf:"bytes,18,rep,name=HH" json:"HH,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"zigzag64,2,opt,name=value"`
|
||||
II map[string]uint32 `protobuf:"bytes,19,rep,name=II" json:"II,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"fixed32,2,opt,name=value"`
|
||||
JJ map[string]uint64 `protobuf:"bytes,20,rep,name=JJ" json:"JJ,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"fixed64,2,opt,name=value"`
|
||||
KK map[string]int32 `protobuf:"bytes,21,rep,name=KK" json:"KK,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"fixed32,2,opt,name=value"`
|
||||
LL map[string]bool `protobuf:"bytes,22,rep,name=LL" json:"LL,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"`
|
||||
MM map[string]string `protobuf:"bytes,23,rep,name=MM" json:"MM,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
|
||||
AAA map[int64]float64 `protobuf:"bytes,31,rep,name=AAA" json:"AAA,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"fixed64,2,opt,name=value"`
|
||||
BBB map[int64]float32 `protobuf:"bytes,32,rep,name=BBB" json:"BBB,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"fixed32,2,opt,name=value"`
|
||||
CCC map[int64]int32 `protobuf:"bytes,33,rep,name=CCC" json:"CCC,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"`
|
||||
DDD map[int64]int64 `protobuf:"bytes,34,rep,name=DDD" json:"DDD,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"`
|
||||
EEE map[int64]uint32 `protobuf:"bytes,35,rep,name=EEE" json:"EEE,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"`
|
||||
FFF map[int64]uint64 `protobuf:"bytes,36,rep,name=FFF" json:"FFF,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"`
|
||||
GGG map[int64]int32 `protobuf:"bytes,37,rep,name=GGG" json:"GGG,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"zigzag32,2,opt,name=value"`
|
||||
HHH map[int64]int64 `protobuf:"bytes,38,rep,name=HHH" json:"HHH,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"zigzag64,2,opt,name=value"`
|
||||
III map[int64]uint32 `protobuf:"bytes,39,rep,name=III" json:"III,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"fixed32,2,opt,name=value"`
|
||||
JJJ map[int64]uint64 `protobuf:"bytes,40,rep,name=JJJ" json:"JJJ,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"fixed64,2,opt,name=value"`
|
||||
KKK map[int64]int32 `protobuf:"bytes,41,rep,name=KKK" json:"KKK,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"fixed32,2,opt,name=value"`
|
||||
LLL map[int64]bool `protobuf:"bytes,42,rep,name=LLL" json:"LLL,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"`
|
||||
MMM map[int64]string `protobuf:"bytes,43,rep,name=MMM" json:"MMM,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
|
||||
}
|
||||
|
||||
func (m *MapTypeResponse) Reset() { *m = MapTypeResponse{} }
|
||||
func (m *MapTypeResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*MapTypeResponse) ProtoMessage() {}
|
||||
func (*MapTypeResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{9} }
|
||||
|
||||
func (m *MapTypeResponse) GetA() *NestedMapMessageA {
|
||||
if m != nil {
|
||||
return m.A
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeResponse) GetB() []*NestedMapMessageB {
|
||||
if m != nil {
|
||||
return m.B
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeResponse) GetAA() map[string]float64 {
|
||||
if m != nil {
|
||||
return m.AA
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeResponse) GetBB() map[string]float32 {
|
||||
if m != nil {
|
||||
return m.BB
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeResponse) GetCC() map[string]int32 {
|
||||
if m != nil {
|
||||
return m.CC
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeResponse) GetDD() map[string]int64 {
|
||||
if m != nil {
|
||||
return m.DD
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeResponse) GetEE() map[string]uint32 {
|
||||
if m != nil {
|
||||
return m.EE
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeResponse) GetFF() map[string]uint64 {
|
||||
if m != nil {
|
||||
return m.FF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeResponse) GetGG() map[string]int32 {
|
||||
if m != nil {
|
||||
return m.GG
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeResponse) GetHH() map[string]int64 {
|
||||
if m != nil {
|
||||
return m.HH
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeResponse) GetII() map[string]uint32 {
|
||||
if m != nil {
|
||||
return m.II
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeResponse) GetJJ() map[string]uint64 {
|
||||
if m != nil {
|
||||
return m.JJ
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeResponse) GetKK() map[string]int32 {
|
||||
if m != nil {
|
||||
return m.KK
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeResponse) GetLL() map[string]bool {
|
||||
if m != nil {
|
||||
return m.LL
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeResponse) GetMM() map[string]string {
|
||||
if m != nil {
|
||||
return m.MM
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeResponse) GetAAA() map[int64]float64 {
|
||||
if m != nil {
|
||||
return m.AAA
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeResponse) GetBBB() map[int64]float32 {
|
||||
if m != nil {
|
||||
return m.BBB
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeResponse) GetCCC() map[int64]int32 {
|
||||
if m != nil {
|
||||
return m.CCC
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeResponse) GetDDD() map[int64]int64 {
|
||||
if m != nil {
|
||||
return m.DDD
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeResponse) GetEEE() map[int64]uint32 {
|
||||
if m != nil {
|
||||
return m.EEE
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeResponse) GetFFF() map[int64]uint64 {
|
||||
if m != nil {
|
||||
return m.FFF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeResponse) GetGGG() map[int64]int32 {
|
||||
if m != nil {
|
||||
return m.GGG
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeResponse) GetHHH() map[int64]int64 {
|
||||
if m != nil {
|
||||
return m.HHH
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeResponse) GetIII() map[int64]uint32 {
|
||||
if m != nil {
|
||||
return m.III
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeResponse) GetJJJ() map[int64]uint64 {
|
||||
if m != nil {
|
||||
return m.JJJ
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeResponse) GetKKK() map[int64]int32 {
|
||||
if m != nil {
|
||||
return m.KKK
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeResponse) GetLLL() map[int64]bool {
|
||||
if m != nil {
|
||||
return m.LLL
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MapTypeResponse) GetMMM() map[int64]string {
|
||||
if m != nil {
|
||||
return m.MMM
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type MapNestedMsg struct {
|
||||
Beta map[int64]*NestedMessageA `protobuf:"bytes,2,rep,name=Beta" json:"Beta,omitempty" protobuf_key:"varint,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
|
||||
}
|
||||
|
||||
func (m *MapNestedMsg) Reset() { *m = MapNestedMsg{} }
|
||||
func (m *MapNestedMsg) String() string { return proto.CompactTextString(m) }
|
||||
func (*MapNestedMsg) ProtoMessage() {}
|
||||
func (*MapNestedMsg) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{10} }
|
||||
|
||||
func (m *MapNestedMsg) GetBeta() map[int64]*NestedMessageA {
|
||||
if m != nil {
|
||||
return m.Beta
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type RepeatedTypes struct {
|
||||
AA []int64 `protobuf:"varint,1,rep,packed,name=AA" json:"AA,omitempty"`
|
||||
BB []string `protobuf:"bytes,2,rep,name=BB" json:"BB,omitempty"`
|
||||
CC []EnumType `protobuf:"varint,3,rep,packed,name=CC,enum=TEST.EnumType" json:"CC,omitempty"`
|
||||
}
|
||||
|
||||
func (m *RepeatedTypes) Reset() { *m = RepeatedTypes{} }
|
||||
func (m *RepeatedTypes) String() string { return proto.CompactTextString(m) }
|
||||
func (*RepeatedTypes) ProtoMessage() {}
|
||||
func (*RepeatedTypes) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{11} }
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*NestedTypeRequest)(nil), "TEST.NestedTypeRequest")
|
||||
proto.RegisterType((*NestedMessageA)(nil), "TEST.NestedMessageA")
|
||||
proto.RegisterType((*NestedMessageB)(nil), "TEST.NestedMessageB")
|
||||
proto.RegisterType((*NestedMessageC)(nil), "TEST.NestedMessageC")
|
||||
proto.RegisterType((*NestedTypeResponse)(nil), "TEST.NestedTypeResponse")
|
||||
proto.RegisterType((*MapTypeRequest)(nil), "TEST.MapTypeRequest")
|
||||
proto.RegisterType((*NestedMapMessageA)(nil), "TEST.NestedMapMessageA")
|
||||
proto.RegisterType((*NestedMapMessageB)(nil), "TEST.NestedMapMessageB")
|
||||
proto.RegisterType((*NestedMapMessageC)(nil), "TEST.NestedMapMessageC")
|
||||
proto.RegisterType((*MapTypeResponse)(nil), "TEST.MapTypeResponse")
|
||||
proto.RegisterType((*MapNestedMsg)(nil), "TEST.MapNestedMsg")
|
||||
proto.RegisterType((*RepeatedTypes)(nil), "TEST.RepeatedTypes")
|
||||
proto.RegisterEnum("TEST.EnumType", EnumType_name, EnumType_value)
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ context.Context
|
||||
var _ grpc.ClientConn
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
const _ = grpc.SupportPackageIsVersion3
|
||||
|
||||
// Client API for Map service
|
||||
|
||||
type MapClient interface {
|
||||
GetMap(ctx context.Context, in *MapTypeRequest, opts ...grpc.CallOption) (*MapTypeResponse, error)
|
||||
PostMap(ctx context.Context, in *MapTypeRequest, opts ...grpc.CallOption) (*MapTypeRequest, error)
|
||||
GetNested(ctx context.Context, in *NestedTypeRequest, opts ...grpc.CallOption) (*NestedTypeResponse, error)
|
||||
PostNested(ctx context.Context, in *NestedTypeRequest, opts ...grpc.CallOption) (*NestedTypeRequest, error)
|
||||
}
|
||||
|
||||
type mapClient struct {
|
||||
cc *grpc.ClientConn
|
||||
}
|
||||
|
||||
func NewMapClient(cc *grpc.ClientConn) MapClient {
|
||||
return &mapClient{cc}
|
||||
}
|
||||
|
||||
func (c *mapClient) GetMap(ctx context.Context, in *MapTypeRequest, opts ...grpc.CallOption) (*MapTypeResponse, error) {
|
||||
out := new(MapTypeResponse)
|
||||
err := grpc.Invoke(ctx, "/TEST.Map/GetMap", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *mapClient) PostMap(ctx context.Context, in *MapTypeRequest, opts ...grpc.CallOption) (*MapTypeRequest, error) {
|
||||
out := new(MapTypeRequest)
|
||||
err := grpc.Invoke(ctx, "/TEST.Map/PostMap", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *mapClient) GetNested(ctx context.Context, in *NestedTypeRequest, opts ...grpc.CallOption) (*NestedTypeResponse, error) {
|
||||
out := new(NestedTypeResponse)
|
||||
err := grpc.Invoke(ctx, "/TEST.Map/GetNested", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *mapClient) PostNested(ctx context.Context, in *NestedTypeRequest, opts ...grpc.CallOption) (*NestedTypeRequest, error) {
|
||||
out := new(NestedTypeRequest)
|
||||
err := grpc.Invoke(ctx, "/TEST.Map/PostNested", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Server API for Map service
|
||||
|
||||
type MapServer interface {
|
||||
GetMap(context.Context, *MapTypeRequest) (*MapTypeResponse, error)
|
||||
PostMap(context.Context, *MapTypeRequest) (*MapTypeRequest, error)
|
||||
GetNested(context.Context, *NestedTypeRequest) (*NestedTypeResponse, error)
|
||||
PostNested(context.Context, *NestedTypeRequest) (*NestedTypeRequest, error)
|
||||
}
|
||||
|
||||
func RegisterMapServer(s *grpc.Server, srv MapServer) {
|
||||
s.RegisterService(&_Map_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _Map_GetMap_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(MapTypeRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MapServer).GetMap(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/TEST.Map/GetMap",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MapServer).GetMap(ctx, req.(*MapTypeRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Map_PostMap_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(MapTypeRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MapServer).PostMap(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/TEST.Map/PostMap",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MapServer).PostMap(ctx, req.(*MapTypeRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Map_GetNested_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(NestedTypeRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MapServer).GetNested(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/TEST.Map/GetNested",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MapServer).GetNested(ctx, req.(*NestedTypeRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Map_PostNested_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(NestedTypeRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MapServer).PostNested(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/TEST.Map/PostNested",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MapServer).PostNested(ctx, req.(*NestedTypeRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _Map_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "TEST.Map",
|
||||
HandlerType: (*MapServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "GetMap",
|
||||
Handler: _Map_GetMap_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "PostMap",
|
||||
Handler: _Map_PostMap_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetNested",
|
||||
Handler: _Map_GetNested_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "PostNested",
|
||||
Handler: _Map_PostNested_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: fileDescriptor0,
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("svc.proto", fileDescriptor0) }
|
||||
|
||||
var fileDescriptor0 = []byte{
|
||||
// 1271 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xec, 0x99, 0xdd, 0x6e, 0xe3, 0x44,
|
||||
0x1c, 0x47, 0xb1, 0xa7, 0xdb, 0x3a, 0xb3, 0xdb, 0x34, 0x35, 0x2d, 0x3b, 0xaa, 0x8a, 0x37, 0x04,
|
||||
0x0a, 0xa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0xc2,
|
||||
0xe9, 0xc9, 0x04, 0xe8, 0x24, 0x61, 0x7b, 0x12, 0x3a, 0x49, 0x38, 0x9d, 0x24, 0x40, 0x4f, 0xa7,
|
||||
0x6c, 0x5f, 0x42, 0x4f, 0xa7, 0x9c, 0x9e, 0x4e, 0x81, 0x4e, 0x53, 0xf6, 0x86, 0x84, 0x4e, 0x53,
|
||||
0x4e, 0xa7, 0x29, 0xd0, 0x59, 0xc6, 0x1e, 0x4b, 0xe8, 0x2c, 0xe3, 0x74, 0x96, 0x99, 0xa7, 0x94,
|
||||
0x78, 0x9e, 0xc7, 0x9e, 0x54, 0xf8, 0x9b, 0x02, 0xad, 0xb8, 0x57, 0x40, 0xc2, 0xc0, 0xf7, 0x7d,
|
||||
0xd6, 0x97, 0x0c, 0xfc, 0x5a, 0x2d, 0x20, 0x61, 0x10, 0x04, 0x01, 0x7b, 0x4b, 0x32, 0x08, 0x6a,
|
||||
0xbb, 0x80, 0x84, 0x41, 0x18, 0x86, 0x6c, 0x20, 0x19, 0x84, 0xb5, 0x60, 0x40, 0xc2, 0x20, 0x8a,
|
||||
0x22, 0xf6, 0xb6, 0x64, 0x10, 0xd5, 0x8e, 0x01, 0x09, 0x83, 0xd1, 0x68, 0xc4, 0xde, 0x91, 0x0c,
|
||||
0x46, 0xb5, 0x66, 0x40, 0xc2, 0x20, 0x8e, 0x63, 0x76, 0x24, 0x19, 0xc4, 0xb5, 0x69, 0x40, 0xc2,
|
||||
0x60, 0x3c, 0x1e, 0xb3, 0x77, 0x25, 0x83, 0x71, 0x2d, 0x1b, 0x90, 0x30, 0x98, 0x4c, 0x26, 0xec,
|
||||
0x3d, 0xc9, 0x60, 0x52, 0xfb, 0x06, 0x24, 0x0c, 0x92, 0x24, 0x61, 0xc7, 0x92, 0x41, 0x52, 0x2b,
|
||||
0x07, 0x24, 0x0c, 0xa6, 0xd3, 0x29, 0x7b, 0x5f, 0x32, 0x98, 0xd6, 0xd6, 0x01, 0x09, 0x83, 0x34,
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xbe, 0xda, 0xac, 0xfe, 0xcf, 0xe9, 0xe3, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0x05,
|
||||
0x3c, 0xbf, 0x46, 0xa4, 0x1a, 0x00, 0x00,
|
||||
}
|
|
@ -0,0 +1,154 @@
|
|||
|
||||
syntax = "proto3";
|
||||
|
||||
package TEST;
|
||||
|
||||
import "google/api/annotations.proto";
|
||||
|
||||
service Map {
|
||||
rpc GetMap (MapTypeRequest) returns (MapTypeResponse) {
|
||||
option (google.api.http) = {
|
||||
get: "/1"
|
||||
};
|
||||
}
|
||||
|
||||
rpc PostMap (MapTypeRequest) returns (MapTypeRequest) {
|
||||
option (google.api.http) = {
|
||||
post: "/2"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
rpc GetNested (NestedTypeRequest) returns (NestedTypeResponse) {
|
||||
option (google.api.http) = {
|
||||
get: "/1"
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
rpc PostNested (NestedTypeRequest) returns (NestedTypeRequest) {
|
||||
option (google.api.http) = {
|
||||
post: "/2"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
message NestedTypeRequest {
|
||||
NestedMessageA A = 1;
|
||||
repeated NestedMessageB B = 17;
|
||||
EnumType C = 18;
|
||||
}
|
||||
|
||||
message NestedMessageA {
|
||||
NestedMessageC A = 1;
|
||||
}
|
||||
|
||||
message NestedMessageB {
|
||||
repeated NestedMessageC A = 1;
|
||||
}
|
||||
|
||||
message NestedMessageC {
|
||||
int64 A = 1;
|
||||
}
|
||||
|
||||
enum EnumType {
|
||||
A = 0;
|
||||
B = 1;
|
||||
C = 2;
|
||||
}
|
||||
|
||||
message NestedTypeResponse {
|
||||
NestedMessageA A = 16;
|
||||
repeated NestedMessageB B = 17;
|
||||
EnumType C = 18;
|
||||
}
|
||||
|
||||
|
||||
message MapTypeRequest {
|
||||
NestedMapMessageA A = 1;
|
||||
repeated NestedMapMessageB B = 2;
|
||||
map<string,double> AA = 11;
|
||||
map<string,float> BB = 12;
|
||||
map<string,int32> CC = 13;
|
||||
map<string,int64> DD = 14;
|
||||
map<string,uint32> EE = 15;
|
||||
map<string,uint64> FF = 16;
|
||||
map<string,sint32> GG = 17;
|
||||
map<string,sint64> HH = 18;
|
||||
map<string,fixed32> II = 19;
|
||||
map<string,fixed64> JJ = 20;
|
||||
map<string,sfixed32> KK = 21;
|
||||
map<string,bool> LL = 22;
|
||||
map<string,string> MM = 23;
|
||||
|
||||
map<int64,double> AAA = 31;
|
||||
map<int64,float> BBB = 32;
|
||||
map<int64,int32> CCC = 33;
|
||||
map<int64,int64> DDD = 34;
|
||||
map<int64,uint32> EEE = 35;
|
||||
map<int64,uint64> FFF = 36;
|
||||
map<int64,sint32> GGG = 37;
|
||||
map<int64,sint64> HHH = 38;
|
||||
map<int64,fixed32> III = 39;
|
||||
map<int64,fixed64> JJJ = 40;
|
||||
map<int64,sfixed32> KKK = 41;
|
||||
map<int64,bool> LLL = 42;
|
||||
map<int64,string> MMM = 43;
|
||||
}
|
||||
|
||||
message NestedMapMessageA {
|
||||
NestedMapMessageC A = 1;
|
||||
}
|
||||
|
||||
message NestedMapMessageB {
|
||||
repeated NestedMapMessageC A = 1;
|
||||
}
|
||||
|
||||
message NestedMapMessageC {
|
||||
map<string,string> A = 1;
|
||||
}
|
||||
|
||||
|
||||
message MapTypeResponse {
|
||||
NestedMapMessageA A = 1;
|
||||
repeated NestedMapMessageB B = 2;
|
||||
map<string,double> AA = 11;
|
||||
map<string,float> BB = 12;
|
||||
map<string,int32> CC = 13;
|
||||
map<string,int64> DD = 14;
|
||||
map<string,uint32> EE = 15;
|
||||
map<string,uint64> FF = 16;
|
||||
map<string,sint32> GG = 17;
|
||||
map<string,sint64> HH = 18;
|
||||
map<string,fixed32> II = 19;
|
||||
map<string,fixed64> JJ = 20;
|
||||
map<string,sfixed32> KK = 21;
|
||||
map<string,bool> LL = 22;
|
||||
map<string,string> MM = 23;
|
||||
|
||||
map<int64,double> AAA = 31;
|
||||
map<int64,float> BBB = 32;
|
||||
map<int64,int32> CCC = 33;
|
||||
map<int64,int64> DDD = 34;
|
||||
map<int64,uint32> EEE = 35;
|
||||
map<int64,uint64> FFF = 36;
|
||||
map<int64,sint32> GGG = 37;
|
||||
map<int64,sint64> HHH = 38;
|
||||
map<int64,fixed32> III = 39;
|
||||
map<int64,fixed64> JJJ = 40;
|
||||
map<int64,sfixed32> KKK = 41;
|
||||
map<int64,bool> LLL = 42;
|
||||
map<int64,string> MMM = 43;
|
||||
}
|
||||
|
||||
message MapNestedMsg {
|
||||
map<int64, NestedMessageA> Beta = 2;
|
||||
}
|
||||
|
||||
message RepeatedTypes {
|
||||
repeated int64 AA = 1;
|
||||
repeated string BB = 2;
|
||||
repeated EnumType CC = 3;
|
||||
}
|
||||
|
Загрузка…
Ссылка в новой задаче