queue

package
v0.76.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2025 License: MIT Imports: 3 Imported by: 0

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:

  1. Given a list of discovered configurations, start with an empty queue.
  2. Sort configurations alphabetically to ensure deterministic ordering of independent items.
  3. 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 Queue

type Queue struct {
	// contains filtered or unexported fields
}

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. Dependencies are guaranteed to come before their dependents. Items with the same dependencies are sorted alphabetically. Passing dependencies that that haven't been checked for cycles 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) Entries

func (q *Queue) Entries() []*discovery.DiscoveredConfig

Entries returns the queue entries. Used for testing.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳