|
| 1 | +package entity |
| 2 | + |
| 3 | +// SpeculationPathAction defines the possible actions for a speculation path. |
| 4 | +type SpeculationPathAction string |
| 5 | + |
| 6 | +const ( |
| 7 | + // SpeculationPathActionUnknown is the default zero value for SpeculationPathAction. |
| 8 | + SpeculationPathActionUnknown SpeculationPathAction = "" |
| 9 | + // TODO: Add comprehensive list of actions |
| 10 | +) |
| 11 | + |
| 12 | +// SpeculationInfo represents metadata about a single speculation path, including the path through the dependency graph, its current state, and the predicted build score. |
| 13 | +type SpeculationInfo struct { |
| 14 | + // Path represents the speculation path; which is an ordered list of batches. |
| 15 | + Path []string |
| 16 | + // Action is a state that this path is in. |
| 17 | + Action SpeculationPathAction |
| 18 | + // Score is score for this speculation path. |
| 19 | + Score float32 |
| 20 | +} |
| 21 | + |
| 22 | +// SpeculationTree represents the set of speculation paths constructed for a batch based on its dependency graph. |
| 23 | +type SpeculationTree struct { |
| 24 | + // BatchID is the batch for which this speculation tree is constructed. |
| 25 | + BatchID string |
| 26 | + // Speculations is a list of speculation paths for this batch based on a graph of its |
| 27 | + // dependents. |
| 28 | + // |
| 29 | + // For e.g - Consider batches - queueA/batch/1, queueA/batch/2, queueA/batch/3 |
| 30 | + // such that - queueA/batch/2 and queueA/batch/3 depend on queueA/batch/1 |
| 31 | + // |
| 32 | + // Speculations for queueA/batch/1 - [{Path: []string{"queueA/batch/1"}, State: "scheduled", Score: 0.1}] |
| 33 | + // Speculations for queueA/batch/2 - [{Path: []string{"queueA/batch/2"}, State: "scheduled", Score: 0.9}, {Path: []string{"queueA/batch/1", "queueA/batch/2"}, State: "scheduled", Score: 0.3}] |
| 34 | + // Speculations for queueA/batch/3 - [{Path: []string{"queueA/batch/3"}, State: "scheduled", Score: 0.9}, {Path: []string{"queueA/batch/1", "queueA/batch/3"}, State: "scheduled", Score: 0.3}] |
| 35 | + // |
| 36 | + Speculations []SpeculationInfo |
| 37 | +} |
0 commit comments