Documentation
¶
Overview ¶
Package queue provides a run queue implementation. The queue is a double-ended queue (deque) that allows for efficient adding and removing of elements from both ends. The queue is used to manage the order of Terragrunt runs.
The algorithm for populating the queue is as follows:
- Given a list of discovered configurations, start with an empty queue.
- Sort configurations alphabetically to ensure deterministic ordering of independent items.
- For each discovered configuration: a. If the configuration has no dependencies, append it to the queue. b. Otherwise, find the position after its last dependency. c. Among items that depend on the same dependency, maintain alphabetical order.
The resulting queue will have: - Configurations with no dependencies at the front - Configurations with dependents are ordered after their dependencies - Alphabetical ordering only between items that share the same dependencies
During operations like applies, entries will be dequeued from the front of the queue and run. During operations like destroys, entries will be dequeued from the back of the queue and run. This ensures that dependencies are satisfied in both cases: - For applies: Dependencies (front) are run before their dependents (back) - For destroys: Dependents (back) are run before their dependencies (front)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entry ¶ added in v0.77.14
type Entry struct {
Config *discovery.DiscoveredConfig
Status Status
}
func (*Entry) UpdateBlocked ¶ added in v0.77.14
UpdateBlocked updates the status of the entry to blocked, if it is blocked. An entry is blocked if:
- It is an "up" command (none of destroy, apply -destroy or plan -destroy) and it has dependencies that are not ready.
- It is a "down" command (destroy, apply -destroy or plan -destroy) and it has dependents that are not ready.
If the entry isn't blocked, then it is marked as unsorted, and is ready to be sorted.
type Queue ¶
type Queue struct {
Entries Entries
}
func NewQueue ¶
func NewQueue(discovered discovery.DiscoveredConfigs) (*Queue, error)
NewQueue creates a new queue from a list of discovered configurations. The queue is populated with the correct Terragrunt run order.
Discovered configurations will be sorted based on two criteria:
The discovery context of the configuration: - If the configuration is for an "up" command (none of destroy, apply -destroy or plan -destroy), it will be inserted at the front of the queue, before its dependencies. - Otherwise, it is considered a "down" command, and will be inserted at the back of the queue, after its dependents.
The name of the configuration. Configurations of the same "level" are sorted alphabetically.
Passing configurations that haven't been checked for cycles in their dependency graph is unsafe. If any cycles are present, the queue construction will halt after N iterations, where N is the number of discovered configs, and throw an error.
func (*Queue) Configs ¶ added in v0.77.14
func (q *Queue) Configs() discovery.DiscoveredConfigs
Configs returns the queue configs.