Note: this could be `graph.walk` or whatever
(ctx context.Context, graph *Graph, eg *errgroup.Group, nodes []*Vertex, nodeCh chan *Vertex)
| 165 | |
| 166 | // Note: this could be `graph.walk` or whatever |
| 167 | func (t *graphTraversal) run(ctx context.Context, graph *Graph, eg *errgroup.Group, nodes []*Vertex, nodeCh chan *Vertex) { |
| 168 | for _, node := range nodes { |
| 169 | // Don't start this service yet if all of its children have |
| 170 | // not been started yet. |
| 171 | if len(t.filterAdjacentByStatusFn(graph, node.Key, t.adjacentServiceStatusToSkip)) != 0 { |
| 172 | continue |
| 173 | } |
| 174 | |
| 175 | if !t.consume(node.Key) { |
| 176 | // another worker already visited this node |
| 177 | continue |
| 178 | } |
| 179 | |
| 180 | eg.Go(func() error { |
| 181 | var err error |
| 182 | if _, ignore := t.ignored[node.Service]; !ignore { |
| 183 | err = t.visitorFn(ctx, node.Service) |
| 184 | } |
| 185 | if err == nil { |
| 186 | graph.UpdateStatus(node.Key, t.targetServiceStatus) |
| 187 | } |
| 188 | nodeCh <- node |
| 189 | return err |
| 190 | }) |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | func (t *graphTraversal) consume(nodeKey string) bool { |
| 195 | t.mu.Lock() |
no test coverage detected