summaryrefslogtreecommitdiff
path: root/app/workers/cluster_wait_for_ingress_ip_address_worker.rb
blob: 0fbb9fb2526f54f344448fe7276b3dd3d33e6cf3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class ClusterWaitForIngressIpAddressWorker
  include ApplicationWorker
  include ClusterQueue
  include ClusterApplications

  INTERVAL = 10.seconds

  def perform(app_name, app_id, retries_remaining)
    find_application(app_name, app_id) do |app|
      result = Clusters::Applications::CheckIngressIpAddressService.new(app).execute
      retry_if_necessary(app_name, app_id, retries_remaining) unless result
    end
  rescue Clusters::Applications::CheckIngressIpAddressService::Error => e
    retry_if_necessary(app_name, app_id, retries_remaining)
    raise e
  end

  private

  def retry_if_necessary(app_name, app_id, retries_remaining)
    if retries_remaining > 0
      self.class.perform_in(INTERVAL, app_name, app_id, retries_remaining - 1)
    end
  end
end