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(application, project) ⇒ ScheduleUpdateService

Returns a new instance of ScheduleUpdateService.


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

def initialize(application, project)
  @application = application
  @project = project
end

Instance Attribute Details

#applicationObject

Returns the value of attribute application


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

def application
  @application
end

#projectObject

Returns the value of attribute project


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

def project
  @project
end

Instance Method Details

#executeObject


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

def execute
  return unless application

  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