Sha256: d5a59cc429a7ec82af008dd65538aff623bad1a3c0bbf5d1e41e1bf8858256b7
Contents?: true
Size: 1.11 KB
Versions: 4
Compression:
Stored size: 1.11 KB
Contents
# frozen_string_literal: true module Facter class InternalFactManager def resolve_facts(searched_facts) searched_facts = filter_internal_facts(searched_facts) threads = start_threads(searched_facts) join_threads(threads, searched_facts) end private def filter_internal_facts(searched_facts) searched_facts.select { |searched_fact| %i[core legacy].include? searched_fact.type } end def start_threads(searched_facts) threads = [] # only resolve a fact once, even if multiple search facts depend on that fact searched_facts .uniq { |searched_fact| searched_fact.fact_class.name } .each do |searched_fact| threads << Thread.new do fact = CoreFact.new(searched_fact) fact.create end end threads end def join_threads(threads, searched_facts) resolved_facts = [] threads.each do |thread| thread.join resolved_facts << thread.value end resolved_facts.flatten! FactAugmenter.augment_resolved_facts(searched_facts, resolved_facts) end end end
Version data entries
4 entries across 4 versions & 1 rubygems