Class: Onair::Orchestrator
- Inherits:
-
Object
- Object
- Onair::Orchestrator
- Defined in:
- lib/onair/orchestrator.rb
Overview
Runs the platform adapter and git concurrently, lazily fetches missing commits at most once, and assembles the Report.
Instance Method Summary collapse
-
#initialize(config:, adapter:, git:, repo: nil) ⇒ Orchestrator
constructor
A new instance of Orchestrator.
- #run ⇒ Object
Constructor Details
#initialize(config:, adapter:, git:, repo: nil) ⇒ Orchestrator
Returns a new instance of Orchestrator.
7 8 9 10 11 12 |
# File 'lib/onair/orchestrator.rb', line 7 def initialize(config:, adapter:, git:, repo: nil) @config = config @adapter = adapter @git = git @repo = repo end |
Instance Method Details
#run ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/onair/orchestrator.rb', line 14 def run snapshot_thread = quiet_thread { @adapter.snapshot } head_thread = quiet_thread { RemoteHead.resolve(git: @git, branch: @config.branch, repo: @repo) } snapshot = snapshot_thread.value remote_head = head_thread.value needed = [snapshot.deployed&.sha, snapshot.pending&.sha, remote_head].compact @git.fetch_once! if needed.any? { |sha| !@git.has_commit?(sha) } Report.build(snapshot: snapshot, remote_head: remote_head, git: @git) end |