Class: Ci::PipelineProcessing::AtomicProcessingService::StatusCollection
- Inherits:
-
Object
- Object
- Ci::PipelineProcessing::AtomicProcessingService::StatusCollection
- Includes:
- Gitlab::Utils::StrongMemoize
- Defined in:
- app/services/ci/pipeline_processing/atomic_processing_service/status_collection.rb
Constant Summary collapse
- STATUSES_COLUMNS =
We use these columns to perform an efficient calculation of a status
[ :id, :name, :status, :allow_failure, :stage_idx, :processed, :lock_version ].freeze
Instance Attribute Summary collapse
-
#pipeline ⇒ Object
readonly
Returns the value of attribute pipeline.
Instance Method Summary collapse
-
#created_processable_ids_for_stage_position(current_position) ⇒ Object
This methods gets a list of processables for a given stage.
-
#initialize(pipeline) ⇒ StatusCollection
constructor
A new instance of StatusCollection.
-
#processing_processables ⇒ Object
This method returns a list of all processable, that are to be processed.
-
#set_processable_status(id, status, lock_version) ⇒ Object
This method updates internal status for given ID.
-
#status_for_names(names, dag:) ⇒ Object
This methods gets composite status for processables with given names.
-
#status_for_prior_stage_position(position) ⇒ Object
This methods gets composite status for processables before given stage.
-
#status_for_stage_position(current_position) ⇒ Object
This methods gets composite status for processables at a given stage.
-
#status_of_all ⇒ Object
This methods gets composite status of all processables.
Methods included from Gitlab::Utils::StrongMemoize
#clear_memoization, #strong_memoize, #strong_memoized?
Constructor Details
#initialize(pipeline) ⇒ StatusCollection
Returns a new instance of StatusCollection.
18 19 20 21 22 |
# File 'app/services/ci/pipeline_processing/atomic_processing_service/status_collection.rb', line 18 def initialize(pipeline) @pipeline = pipeline @stage_statuses = {} @prior_stage_statuses = {} end |
Instance Attribute Details
#pipeline ⇒ Object (readonly)
Returns the value of attribute pipeline
9 10 11 |
# File 'app/services/ci/pipeline_processing/atomic_processing_service/status_collection.rb', line 9 def pipeline @pipeline end |
Instance Method Details
#created_processable_ids_for_stage_position(current_position) ⇒ Object
This methods gets a list of processables for a given stage
56 57 58 59 60 61 |
# File 'app/services/ci/pipeline_processing/atomic_processing_service/status_collection.rb', line 56 def created_processable_ids_for_stage_position(current_position) all_statuses_grouped_by_stage_position[current_position] .to_a .select { |processable| processable[:status] == 'created' } .map { |processable| processable[:id] } end |
#processing_processables ⇒ Object
This method returns a list of all processable, that are to be processed
73 74 75 |
# File 'app/services/ci/pipeline_processing/atomic_processing_service/status_collection.rb', line 73 def processing_processables all_statuses.lazy.reject { |status| status[:processed] } end |
#set_processable_status(id, status, lock_version) ⇒ Object
This method updates internal status for given ID
25 26 27 28 29 30 31 |
# File 'app/services/ci/pipeline_processing/atomic_processing_service/status_collection.rb', line 25 def set_processable_status(id, status, lock_version) processable = all_statuses_by_id[id] return unless processable processable[:status] = status processable[:lock_version] = lock_version end |
#status_for_names(names, dag:) ⇒ Object
This methods gets composite status for processables with given names
39 40 41 42 43 |
# File 'app/services/ci/pipeline_processing/atomic_processing_service/status_collection.rb', line 39 def status_for_names(names, dag:) name_statuses = all_statuses_by_name.slice(*names) status_for_array(name_statuses.values, dag: dag) end |
#status_for_prior_stage_position(position) ⇒ Object
This methods gets composite status for processables before given stage
46 47 48 49 50 51 52 53 |
# File 'app/services/ci/pipeline_processing/atomic_processing_service/status_collection.rb', line 46 def status_for_prior_stage_position(position) strong_memoize("status_for_prior_stage_position_#{position}") do stage_statuses = all_statuses_grouped_by_stage_position .select { |stage_position, _| stage_position < position } status_for_array(stage_statuses.values.flatten, dag: false) end end |
#status_for_stage_position(current_position) ⇒ Object
This methods gets composite status for processables at a given stage
64 65 66 67 68 69 70 |
# File 'app/services/ci/pipeline_processing/atomic_processing_service/status_collection.rb', line 64 def status_for_stage_position(current_position) strong_memoize("status_for_stage_position_#{current_position}") do stage_statuses = all_statuses_grouped_by_stage_position[current_position].to_a status_for_array(stage_statuses.flatten, dag: false) end end |
#status_of_all ⇒ Object
This methods gets composite status of all processables
34 35 36 |
# File 'app/services/ci/pipeline_processing/atomic_processing_service/status_collection.rb', line 34 def status_of_all status_for_array(all_statuses, dag: false) end |