Class: Clusters::Applications::ScheduleUpdateService

Inherits:
Object
  • Object
show all
Defined in:
app/services/clusters/applications/schedule_update_service.rb

Constant Summary collapse

BACKOFF_DELAY =
2.minutes

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cluster_prometheus_adapter, project) ⇒ ScheduleUpdateService

Returns a new instance of ScheduleUpdateService.


11
12
13
14
# File 'app/services/clusters/applications/schedule_update_service.rb', line 11

def initialize(cluster_prometheus_adapter, project)
  @application = cluster_prometheus_adapter&.cluster&.application_prometheus
  @project = project
end

Instance Attribute Details

#applicationObject

Returns the value of attribute application.


9
10
11
# File 'app/services/clusters/applications/schedule_update_service.rb', line 9

def application
  @application
end

#projectObject

Returns the value of attribute project.


9
10
11
# File 'app/services/clusters/applications/schedule_update_service.rb', line 9

def project
  @project
end

Instance Method Details

#executeObject


16
17
18
19
20
21
22
23
24
25
# File 'app/services/clusters/applications/schedule_update_service.rb', line 16

def execute
  return unless application
  return if application.externally_installed?

  if recently_scheduled?
    worker_class.perform_in(BACKOFF_DELAY, application.name, application.id, project.id, Time.current)
  else
    worker_class.perform_async(application.name, application.id, project.id, Time.current)
  end
end