func parseGenDecl(bci *BenchClientInfo, decl *ast.GenDecl) {
	if decl.Tok != token.TYPE {
		return
	}

	for _, s := range decl.Specs {
		ts := s.(*ast.TypeSpec)
		iface, ok := ts.Type.(*ast.InterfaceType)
		if !ok {
			continue
		}

		ifaceName := ts.Name.String()
		if !strings.HasSuffix(ifaceName, "Client") {
			continue
		}
		if strings.Index(ifaceName, "Service_") > 0 {
			// TODO: support streaming RPC
			continue
		}
		bci.Services[ifaceName] = &service{RPCs: make(map[string]rpc)}

		for _, m := range iface.Methods.List {
			methodName := m.Names[0].String()
			mt := m.Type.(*ast.FuncType)

			var streaming bool
			for _, r := range mt.Results.List {
				if strings.Index(types.ExprString(r.Type), "Service_") > 0 {
					// TODO: support streaming RPC
					streaming = true
					break
				}
			}

			switch {
			case mt.Params.NumFields() == unaryArgs && !streaming:
				argName := types.ExprString(mt.Params.List[1].Type)[1:]
				bci.Services[ifaceName].RPCs[methodName] = rpc{Unary: true, In: argName}
			default:
				// TODO: support streaming RPC
				bci.Services[ifaceName].RPCs[methodName] = rpc{Stream: true}
			}
		}
	}
}
// parseGenDecl searches interfaces and its methods of Client API from decl,
// and add it to BenchClientInfo.
parseGenDecl searches interfaces and its methods of Client API from decl,
and add it to BenchClientInfo.
// parseGenDecl searches interfaces and its methods of Client API from decl // and add it to BenchClientInfo .
func parseGenDecl(bci *BenchClientInfo, decl *ast.GenDecl) {
	if decl.Tok != token.TYPE {
		return
	}
	for _, s := range decl.Specs {
		ts := s.(*ast.TypeSpec)
		iface, ok := ts.Type.(*ast.InterfaceType)
		if !ok {
			continue
		}
		ifaceName := ts.Name.String()
		if !strings.HasSuffix(ifaceName, "Client") {
			continue
		}
		if strings.Index(ifaceName, "Service_") > 0 {
			continue
		}
		bci.Services[ifaceName] = &service{RPCs: make(map[string]rpc)}
		for _, m := range iface.Methods.List {
			methodName := m.Names[0].String()
			mt := m.Type.(*ast.FuncType)
			var streaming bool
			for _, r := range mt.Results.List {
				if strings.Index(types.ExprString(r.Type), "Service_") > 0 {
					streaming = true
					break
				}
			}
			switch {
			case mt.Params.NumFields() == unaryArgs && !streaming:
				argName := types.ExprString(mt.Params.List[1].Type)[1:]
				bci.Services[ifaceName].RPCs[methodName] = rpc{Unary: true, In: argName}
			default:
				bci.Services[ifaceName].RPCs[methodName] = rpc{Stream: true}
			}
		}
	}
}
func parseGenDecl ( bci * BenchClientInfo , decl * ast . GenDecl ) { if decl . Tok != token . TYPE { return } for _ , s := range decl . Specs { ts := s . ( * ast . TypeSpec ) iface , ok := ts . Type . ( * ast . InterfaceType ) if ! ok { continue } ifaceName := ts . Name . String ( ) if ! strings . HasSuffix ( ifaceName , " " ) { continue } if strings . Index ( ifaceName , " " ) > 0 { continue } bci . Services [ ifaceName ] = & service { RPCs : make ( map [ string ] rpc ) } for _ , m := range iface . Methods . List { methodName := m . Names [ 0 ] . String ( ) mt := m . Type . ( * ast . FuncType ) var streaming bool for _ , r := range mt . Results . List { if strings . Index ( types . ExprString ( r . Type ) , " " ) > 0 { streaming = true break } } switch { case mt . Params . NumFields ( ) == unaryArgs && ! streaming : argName := types . ExprString ( mt . Params . List [ 1 ] . Type ) [ 1 : ] bci . Services [ ifaceName ] . RPCs [ methodName ] = rpc { Unary : true , In : argName } default : bci . Services [ ifaceName ] . RPCs [ methodName ] = rpc { Stream : true } } } } }
parseGenDecl searches interfaces and its methods of Client API from decl,
and add it to BenchClientInfo.
parseGenDecl searches interfaces and its methods of Client API from decl and add it to BenchClientInfo .
// TODO: support streaming RPC // TODO: support streaming RPC // TODO: support streaming RPC