|
|
|
@ -57,7 +57,7 @@ func GetResolveFields(ctx *Context, p graphql.ResolveParams) []string {
|
|
|
|
|
|
|
|
|
|
func ResolveNodes(ctx *ResolveContext, p graphql.ResolveParams, ids []NodeID) ([]NodeResult, error) {
|
|
|
|
|
fields := GetResolveFields(ctx.Context, p)
|
|
|
|
|
ctx.Context.Log.Logf("gql", "RESOLVE_NODES(%+v): %+v", ids, fields)
|
|
|
|
|
ctx.Context.Log.Logf("gql_resolve_node", "RESOLVE_NODES(%+v): %+v", ids, fields)
|
|
|
|
|
|
|
|
|
|
resp_channels := map[uuid.UUID]chan Signal{}
|
|
|
|
|
indices := map[uuid.UUID]int{}
|
|
|
|
@ -67,7 +67,7 @@ func ResolveNodes(ctx *ResolveContext, p graphql.ResolveParams, ids []NodeID) ([
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
ctx.Context.Log.Logf("gql", "ACL Fields from request: %+v", ext_fields)
|
|
|
|
|
ctx.Context.Log.Logf("gql_resolve_node", "ACL Fields from request: %+v", ext_fields)
|
|
|
|
|
|
|
|
|
|
responses := make([]NodeResult, len(ids))
|
|
|
|
|
|
|
|
|
@ -100,14 +100,14 @@ func ResolveNodes(ctx *ResolveContext, p graphql.ResolveParams, ids []NodeID) ([
|
|
|
|
|
|
|
|
|
|
if resolve == true {
|
|
|
|
|
read_signal = NewReadSignal(missing_exts)
|
|
|
|
|
ctx.Context.Log.Logf("gql_node", "sending read for %+v because of missing fields %+v", id, missing_exts)
|
|
|
|
|
ctx.Context.Log.Logf("gql_resolve_node", "sending read for %+v because of missing fields %+v", id, missing_exts)
|
|
|
|
|
} else {
|
|
|
|
|
ctx.Context.Log.Logf("gql_node", "Using cached response for %+v(%d)", id, i)
|
|
|
|
|
ctx.Context.Log.Logf("gql_resolve_node", "Using cached response for %+v(%d)", id, i)
|
|
|
|
|
responses[i] = node
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
ctx.Context.Log.Logf("gql_node", "sending read for %+v", id)
|
|
|
|
|
ctx.Context.Log.Logf("gql_resolve_node", "sending read for %+v", id)
|
|
|
|
|
read_signal = NewReadSignal(ext_fields)
|
|
|
|
|
}
|
|
|
|
|
// Create a read signal, send it to the specified node, and add the wait to the response map if the send returns no error
|
|
|
|
@ -124,8 +124,6 @@ func ResolveNodes(ctx *ResolveContext, p graphql.ResolveParams, ids []NodeID) ([
|
|
|
|
|
ctx.Ext.FreeResponseChannel(read_signal.ID())
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ctx.Context.Log.Logf("gql_node", "SENT_READ_SIGNAL to %+s", id)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
errors := ""
|
|
|
|
@ -135,7 +133,7 @@ func ResolveNodes(ctx *ResolveContext, p graphql.ResolveParams, ids []NodeID) ([
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
ctx.Context.Log.Logf("gql_node", "GQL node response: %+v", response)
|
|
|
|
|
ctx.Context.Log.Logf("gql_resolve_node", "GQL node response: %+v", response)
|
|
|
|
|
|
|
|
|
|
error_signal, is_error := response.(*ErrorSignal)
|
|
|
|
|
if is_error {
|
|
|
|
@ -158,6 +156,7 @@ func ResolveNodes(ctx *ResolveContext, p graphql.ResolveParams, ids []NodeID) ([
|
|
|
|
|
|
|
|
|
|
cache, exists := ctx.NodeCache[read_response.NodeID]
|
|
|
|
|
if exists == true {
|
|
|
|
|
ctx.Context.Log.Logf("gql_resolve_node", "Merging new response with cached: %s, %+v - %+v", read_response.NodeID, cache, read_response.Extensions)
|
|
|
|
|
for ext_type, fields := range(read_response.Extensions) {
|
|
|
|
|
cached_fields, exists := cache.Data[ext_type]
|
|
|
|
|
if exists == true {
|
|
|
|
@ -166,15 +165,18 @@ func ResolveNodes(ctx *ResolveContext, p graphql.ResolveParams, ids []NodeID) ([
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// TODO: put the cached results back into results to resolve
|
|
|
|
|
responses[idx] = cache
|
|
|
|
|
} else {
|
|
|
|
|
ctx.Context.Log.Logf("gql_resolve_node", "Adding new response to node cache: %s, %+v", read_response.NodeID, read_response.Extensions)
|
|
|
|
|
ctx.NodeCache[read_response.NodeID] = responses[idx]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
ctx.Context.Log.Logf("gql_node", "RESOLVED_NODES %+v - %+v", ids, responses)
|
|
|
|
|
|
|
|
|
|
if errors != "" {
|
|
|
|
|
return nil, fmt.Errorf(errors)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ctx.Context.Log.Logf("gql_resolve_node", "RESOLVED_NODES %+v - %+v", ids, responses)
|
|
|
|
|
return responses, nil
|
|
|
|
|
}
|
|
|
|
|