mirror of
https://github.com/foomo/gotsrpc.git
synced 2025-10-16 12:35:35 +00:00
fix: collected nested types
This commit is contained in:
parent
6ca8be109d
commit
ef0be4b5bc
@ -115,6 +115,9 @@ export class ServiceClient {
|
||||
async interfaceSlice(v:Array<any>|null):Promise<Array<any>|null> {
|
||||
return (await this.transport<{0:Array<any>|null}>("InterfaceSlice", [v]))[0]
|
||||
}
|
||||
async nestedType():Promise<github_com_foomo_gotsrpc_v2_example_basic_service.NestedType|null> {
|
||||
return (await this.transport<{0:github_com_foomo_gotsrpc_v2_example_basic_service.NestedType|null}>("NestedType", []))[0]
|
||||
}
|
||||
async string(v:string):Promise<string> {
|
||||
return (await this.transport<{0:string}>("String", [v]))[0]
|
||||
}
|
||||
|
||||
@ -86,6 +86,16 @@ export enum IntTypeMapValue {
|
||||
IntATypeMapValue = 1,
|
||||
IntBTypeMapValue = 2,
|
||||
}
|
||||
// github.com/foomo/gotsrpc/v2/example/basic/service.NestedSubType
|
||||
export interface NestedSubType {
|
||||
Foo:string;
|
||||
}
|
||||
// github.com/foomo/gotsrpc/v2/example/basic/service.NestedType
|
||||
export type NestedType = Record<github_com_foomo_gotsrpc_v2_example_basic_service.NestedTypeKey,Record<github_com_foomo_gotsrpc_v2_example_basic_service.NestedTypeSubKey,Array<github_com_foomo_gotsrpc_v2_example_basic_service.NestedSubType|null>|null>|null>
|
||||
// github.com/foomo/gotsrpc/v2/example/basic/service.NestedTypeKey
|
||||
export type NestedTypeKey = string
|
||||
// github.com/foomo/gotsrpc/v2/example/basic/service.NestedTypeSubKey
|
||||
export type NestedTypeSubKey = string
|
||||
// github.com/foomo/gotsrpc/v2/example/basic/service.StringType
|
||||
export enum StringType {
|
||||
StringAType = "A",
|
||||
|
||||
@ -271,6 +271,12 @@ type (
|
||||
RetInterfaceSlice_0 []interface{}
|
||||
}
|
||||
|
||||
ServiceNestedTypeRequest struct {
|
||||
}
|
||||
ServiceNestedTypeResponse struct {
|
||||
RetNestedType_0 NestedType
|
||||
}
|
||||
|
||||
ServiceStringRequest struct {
|
||||
V string
|
||||
}
|
||||
@ -520,6 +526,8 @@ func init() {
|
||||
gob.Register(ServiceInterfaceResponse{})
|
||||
gob.Register(ServiceInterfaceSliceRequest{})
|
||||
gob.Register(ServiceInterfaceSliceResponse{})
|
||||
gob.Register(ServiceNestedTypeRequest{})
|
||||
gob.Register(ServiceNestedTypeResponse{})
|
||||
gob.Register(ServiceStringRequest{})
|
||||
gob.Register(ServiceStringResponse{})
|
||||
gob.Register(ServiceStringMapRequest{})
|
||||
@ -753,6 +761,9 @@ func (p *ServiceGoRPCProxy) handler(clientAddr string, request interface{}) (res
|
||||
req := request.(ServiceInterfaceSliceRequest)
|
||||
retInterfaceSlice_0 := p.service.InterfaceSlice(req.V)
|
||||
response = ServiceInterfaceSliceResponse{RetInterfaceSlice_0: retInterfaceSlice_0}
|
||||
case "ServiceNestedTypeRequest":
|
||||
retNestedType_0 := p.service.NestedType()
|
||||
response = ServiceNestedTypeResponse{RetNestedType_0: retNestedType_0}
|
||||
case "ServiceStringRequest":
|
||||
req := request.(ServiceStringRequest)
|
||||
retString_0 := p.service.String(req.V)
|
||||
|
||||
@ -425,6 +425,17 @@ func (tsc *ServiceGoRPCClient) InterfaceSlice(v []interface{}) (retInterfaceSlic
|
||||
return response.RetInterfaceSlice_0, nil
|
||||
}
|
||||
|
||||
func (tsc *ServiceGoRPCClient) NestedType() (retNestedType_0 NestedType, clientErr error) {
|
||||
req := ServiceNestedTypeRequest{}
|
||||
rpcCallRes, rpcCallErr := tsc.Client.Call(req)
|
||||
if rpcCallErr != nil {
|
||||
clientErr = rpcCallErr
|
||||
return
|
||||
}
|
||||
response := rpcCallRes.(ServiceNestedTypeResponse)
|
||||
return response.RetNestedType_0, nil
|
||||
}
|
||||
|
||||
func (tsc *ServiceGoRPCClient) String(v string) (retString_0 string, clientErr error) {
|
||||
req := ServiceStringRequest{V: v}
|
||||
rpcCallRes, rpcCallErr := tsc.Client.Call(req)
|
||||
|
||||
@ -47,6 +47,7 @@ const (
|
||||
ServiceGoTSRPCProxyIntTypeMapTyped = "IntTypeMapTyped"
|
||||
ServiceGoTSRPCProxyInterface = "Interface"
|
||||
ServiceGoTSRPCProxyInterfaceSlice = "InterfaceSlice"
|
||||
ServiceGoTSRPCProxyNestedType = "NestedType"
|
||||
ServiceGoTSRPCProxyString = "String"
|
||||
ServiceGoTSRPCProxyStringMap = "StringMap"
|
||||
ServiceGoTSRPCProxyStringSlice = "StringSlice"
|
||||
@ -926,6 +927,21 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request)
|
||||
}
|
||||
gotsrpc.Monitor(w, r, args, rets, callStats)
|
||||
return
|
||||
case ServiceGoTSRPCProxyNestedType:
|
||||
var (
|
||||
args []interface{}
|
||||
rets []interface{}
|
||||
)
|
||||
executionStart := time.Now()
|
||||
nestedTypeRet := p.service.NestedType()
|
||||
callStats.Execution = time.Since(executionStart)
|
||||
rets = []interface{}{nestedTypeRet}
|
||||
if err := gotsrpc.Reply(rets, callStats, r, w); err != nil {
|
||||
gotsrpc.ErrorCouldNotReply(w)
|
||||
return
|
||||
}
|
||||
gotsrpc.Monitor(w, r, args, rets, callStats)
|
||||
return
|
||||
case ServiceGoTSRPCProxyString:
|
||||
var (
|
||||
args []interface{}
|
||||
|
||||
@ -47,6 +47,7 @@ type ServiceGoTSRPCClient interface {
|
||||
IntTypeMapTyped(ctx go_context.Context, v IntTypeMapTyped) (retIntTypeMapTyped_0 IntTypeMapTyped, clientErr error)
|
||||
Interface(ctx go_context.Context, v interface{}) (retInterface_0 interface{}, clientErr error)
|
||||
InterfaceSlice(ctx go_context.Context, v []interface{}) (retInterfaceSlice_0 []interface{}, clientErr error)
|
||||
NestedType(ctx go_context.Context) (retNestedType_0 NestedType, clientErr error)
|
||||
String(ctx go_context.Context, v string) (retString_0 string, clientErr error)
|
||||
StringMap(ctx go_context.Context, v map[string]interface{}) (retStringMap_0 map[string]interface{}, clientErr error)
|
||||
StringSlice(ctx go_context.Context, v []string) (retStringSlice_0 []string, clientErr error)
|
||||
@ -455,6 +456,16 @@ func (tsc *HTTPServiceGoTSRPCClient) InterfaceSlice(ctx go_context.Context, v []
|
||||
return
|
||||
}
|
||||
|
||||
func (tsc *HTTPServiceGoTSRPCClient) NestedType(ctx go_context.Context) (retNestedType_0 NestedType, clientErr error) {
|
||||
args := []interface{}{}
|
||||
reply := []interface{}{&retNestedType_0}
|
||||
clientErr = tsc.Client.Call(ctx, tsc.URL, tsc.EndPoint, "NestedType", args, reply)
|
||||
if clientErr != nil {
|
||||
clientErr = pkg_errors.WithMessage(clientErr, "failed to call service.ServiceGoTSRPCProxy NestedType")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (tsc *HTTPServiceGoTSRPCClient) String(ctx go_context.Context, v string) (retString_0 string, clientErr error) {
|
||||
args := []interface{}{v}
|
||||
reply := []interface{}{&retString_0}
|
||||
|
||||
@ -62,4 +62,14 @@ type Service interface {
|
||||
Float32Type(v Float32Type) Float32Type
|
||||
Float64Type(v Float64Type) Float64Type
|
||||
StringType(v StringType) StringType
|
||||
NestedType() NestedType
|
||||
}
|
||||
|
||||
type (
|
||||
NestedType map[NestedTypeKey]map[NestedTypeSubKey][]*NestedSubType
|
||||
NestedTypeKey string
|
||||
NestedTypeSubKey string
|
||||
NestedSubType struct {
|
||||
Foo string
|
||||
}
|
||||
)
|
||||
|
||||
@ -631,26 +631,17 @@ func (s *Struct) DepsSatisfied(missingTypes map[string]bool, structs map[string]
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
if s.Array != nil && s.Array.Value != nil {
|
||||
if s.Array.Value.StructType != nil {
|
||||
if needsWork(s.Array.Value.StructType.FullName()) {
|
||||
return false
|
||||
}
|
||||
} else if s.Array.Value.Scalar != nil {
|
||||
if needsWork(s.Array.Value.Scalar.FullName()) {
|
||||
return false
|
||||
}
|
||||
if s.Array != nil {
|
||||
if s.Array.Value != nil && needsWorkValue(s.Array.Value, needsWork) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if s.Map != nil && s.Map.Value != nil {
|
||||
if s.Map.Value.StructType != nil {
|
||||
if needsWork(s.Map.Value.StructType.FullName()) {
|
||||
return false
|
||||
}
|
||||
} else if s.Map.Value.Scalar != nil {
|
||||
if needsWork(s.Map.Value.Scalar.FullName()) {
|
||||
return false
|
||||
}
|
||||
if s.Map != nil {
|
||||
if s.Map.Key != nil && needsWorkValue(s.Map.Key, needsWork) {
|
||||
return false
|
||||
}
|
||||
if s.Map.Value != nil && needsWorkValue(s.Map.Value, needsWork) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return !needsWork(s.FullName())
|
||||
|
||||
Loading…
Reference in New Issue
Block a user