Documentation ¶
Overview ¶
Package clientarggen collects information for templating the code in a truss-generated client which marshals command line flags into message fields for each service. Functions and fields in clientargen are called by templates in protoc-gen-truss-gokit/template/
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ProtoToGoTypeMap = map[string]string{
"TYPE_DOUBLE": "float64",
"TYPE_FLOAT": "float32",
"TYPE_INT64": "int64",
"TYPE_UINT64": "uint64",
"TYPE_INT32": "int32",
"TYPE_UINT32": "uint32",
"TYPE_FIXED64": "uint64",
"TYPE_FIXED32": "uint32",
"TYPE_BOOL": "bool",
"TYPE_STRING": "string",
"TYPE_SFIXED32": "int32",
"TYPE_SFIXED64": "int64",
"TYPE_SINT32": "int32",
"TYPE_SINT64": "int64",
}
Functions ¶
This section is empty.
Types ¶
type ClientArg ¶
type ClientArg struct { Name string FlagName string FlagArg string ProtbufType string GoType string FlagConvertFunc string IsBaseType bool }
A collection of the necessary information for generating basic business logic in the client. This business logic will allow the generated client to:
- Have command line flags of the correct go types
- Place correctly named and typed arguments in each request method
- Create a request struct with the the function arguments as fields
Since we can only automatically generate handlers for some basic types, if a ClientArg is for a field that's not a base type (such as if it's an embedded message) then the developer is going to have to write a handler for that themselves.
type ClientServiceArgs ¶
type ClientServiceArgs struct {
MethArgs map[string]*MethodArgs
}
func New ¶
func New(svc *doctree.ProtoService) *ClientServiceArgs
New creates a ClientServiceArgs struct containing all the arguments for all the methods of a given RPC.
func (*ClientServiceArgs) AllFlags ¶
func (self *ClientServiceArgs) AllFlags() string
AllFlags returns a string that is all the flag declarations for all arguments of all methods, separated by newlines. This is used in the template to declare all the flag arguments for a client at once, and without doing all this iteration in a template where it would be much less understandable.
type MethodArgs ¶
type MethodArgs struct {
Args []*ClientArg
}
func (*MethodArgs) CallArgs ¶
func (self *MethodArgs) CallArgs() string
CallArgs returns a string for the variables to pass to a function implementing this method. Example:
request, _ := clientHandler.Sum(ASum, BSum) └──────────┘
func (*MethodArgs) FunctionArgs ¶
func (self *MethodArgs) FunctionArgs() string
FunctionArgs returns a string for the arguments of the function signature for a given method. E.g. If there where a method "Sum" with arguments "A" and "B", this would generate the arguments portion of a function declaration like this:
func Sum(ASum int64, BSum int64) (pb.SumRequest, error) { └────────────────────┘