mirror of
https://github.com/foomo/gotsrpc.git
synced 2025-10-16 12:35:35 +00:00
fixed an issue with resolving scalar types in structs and sorting service methods in order to avoid unnessary file changes
This commit is contained in:
parent
e2612d8352
commit
76a667423a
8
model.go
8
model.go
@ -49,9 +49,15 @@ type Field struct {
|
||||
|
||||
type Service struct {
|
||||
Name string
|
||||
Methods []*Method
|
||||
Methods ServiceMethods
|
||||
}
|
||||
|
||||
type ServiceMethods []*Method
|
||||
|
||||
func (sm ServiceMethods) Len() int { return len(sm) }
|
||||
func (sm ServiceMethods) Swap(i, j int) { sm[i], sm[j] = sm[j], sm[i] }
|
||||
func (sm ServiceMethods) Less(i, j int) bool { return sm[i].Name < sm[j].Name }
|
||||
|
||||
type Method struct {
|
||||
Name string
|
||||
Args []*Field
|
||||
|
||||
@ -7,6 +7,7 @@ import (
|
||||
"go/token"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -57,7 +58,9 @@ func readServiceFile(file *ast.File, packageName string, services []*Service) er
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, s := range services {
|
||||
sort.Sort(s.Methods)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -366,14 +369,15 @@ func typesPending(structs map[string]*Struct, scalars map[string]*Scalar, missin
|
||||
|
||||
func (s *Struct) DepsSatisfied(missingTypes map[string]bool, structs map[string]*Struct, scalarTypes map[string]*Scalar) bool {
|
||||
needsWork := func(fullName string) bool {
|
||||
strct, ok := structs[fullName]
|
||||
if !ok {
|
||||
strct, strctOK := structs[fullName]
|
||||
scalar, scalarOK := scalarTypes[fullName]
|
||||
if !strctOK && !scalarOK {
|
||||
// hey there is more todo
|
||||
missingTypes[fullName] = true
|
||||
trace("need work ----------------------" + fullName)
|
||||
return true
|
||||
}
|
||||
if strct == nil {
|
||||
if strct == nil && scalar == nil {
|
||||
trace("need work ----------------------" + fullName)
|
||||
return true
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user