Class: Gitlab::Memory::UploadAndCleanupReports

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/memory/upload_and_cleanup_reports.rb

Constant Summary collapse

DEFAULT_SLEEP_TIME_SECONDS =

15 minutes

900

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uploader:, reports_path:, logger:, sleep_time_seconds: ENV['GITLAB_DIAGNOSTIC_REPORTS_UPLOADER_SLEEP_S']&.to_i || DEFAULT_SLEEP_TIME_SECONDS) ⇒ UploadAndCleanupReports

Returns a new instance of UploadAndCleanupReports.



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/gitlab/memory/upload_and_cleanup_reports.rb', line 8

def initialize(
  uploader:,
  reports_path:,
  logger:,
  sleep_time_seconds: ENV['GITLAB_DIAGNOSTIC_REPORTS_UPLOADER_SLEEP_S']&.to_i || DEFAULT_SLEEP_TIME_SECONDS)

  @uploader = uploader
  @reports_path = reports_path
  @sleep_time_seconds = sleep_time_seconds
  @alive = true
  @logger = logger
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



21
22
23
# File 'lib/gitlab/memory/upload_and_cleanup_reports.rb', line 21

def logger
  @logger
end

#reports_pathObject (readonly)

Returns the value of attribute reports_path.



21
22
23
# File 'lib/gitlab/memory/upload_and_cleanup_reports.rb', line 21

def reports_path
  @reports_path
end

#sleep_time_secondsObject (readonly)

Returns the value of attribute sleep_time_seconds.



21
22
23
# File 'lib/gitlab/memory/upload_and_cleanup_reports.rb', line 21

def sleep_time_seconds
  @sleep_time_seconds
end

#uploaderObject (readonly)

Returns the value of attribute uploader.



21
22
23
# File 'lib/gitlab/memory/upload_and_cleanup_reports.rb', line 21

def uploader
  @uploader
end

Instance Method Details

#callObject



23
24
25
26
27
28
29
30
31
# File 'lib/gitlab/memory/upload_and_cleanup_reports.rb', line 23

def call
  log_started

  loop do
    sleep(sleep_time_seconds)

    files_to_process.each { |path| upload_and_cleanup!(path) }
  end
end