mirror of https://github.com/grafana/grafana.git
				
				
				
			SSE: Update execution order to move DS queries first (#105686)
This is part of getting SSE more consistent when run from the query service vs part of grafana-server. fixes #105680
This commit is contained in:
		
							parent
							
								
									b6c9ecf7fe
								
							
						
					
					
						commit
						005f390df4
					
				|  | @ -211,19 +211,29 @@ func (s *Service) buildDependencyGraph(req *Request) (*simple.DirectedGraph, err | |||
| 
 | ||||
| // buildExecutionOrder returns a sequence of nodes ordered by dependency.
 | ||||
| // Note: During execution, Datasource query nodes for the same datasource will
 | ||||
| // be grouped into one request and executed first as phase after this call.
 | ||||
| // be grouped into one request and executed first as phase after this call
 | ||||
| // If the groupByDSFlag is enabled.
 | ||||
| func buildExecutionOrder(graph *simple.DirectedGraph) ([]Node, error) { | ||||
| 	sortedNodes, err := topo.SortStabilized(graph, nil) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 
 | ||||
| 	nodes := make([]Node, len(sortedNodes)) | ||||
| 	for i, v := range sortedNodes { | ||||
| 		nodes[i] = v.(Node) | ||||
| 	var dsNodes []Node | ||||
| 	var otherNodes []Node | ||||
| 
 | ||||
| 	for _, v := range sortedNodes { | ||||
| 		n := v.(Node) | ||||
| 		switch n.NodeType() { | ||||
| 		case TypeDatasourceNode, TypeMLNode: | ||||
| 			dsNodes = append(dsNodes, n) | ||||
| 		default: | ||||
| 			otherNodes = append(otherNodes, n) | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	return nodes, nil | ||||
| 	// Datasource/ML nodes come first, followed by all others, in original topo order
 | ||||
| 	return append(dsNodes, otherNodes...), nil | ||||
| } | ||||
| 
 | ||||
| // buildNodeRegistry returns a lookup table for reference IDs to respective node.
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue