debian-mirror-gitlab/lib/gitlab/database/background_migration/health_status/signals.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

74 lines
1.8 KiB
Ruby
Raw Normal View History

2022-08-13 15:12:31 +05:30
# frozen_string_literal: true
module Gitlab
module Database
module BackgroundMigration
module HealthStatus
module Signals
# Base class for a signal
class Base
attr_reader :indicator_class, :reason
def initialize(indicator_class, reason:)
@indicator_class = indicator_class
@reason = reason
end
def to_s
"#{short_name} (indicator: #{indicator_class}; reason: #{reason})"
end
# :nocov:
def log_info?
false
end
2022-08-27 11:52:29 +05:30
def stop?
false
end
2022-08-13 15:12:31 +05:30
# :nocov:
private
def short_name
self.class.name.demodulize
end
end
# A Signals::Stop is an indication to put a migration on hold or stop it entirely:
# In general, we want to slow down or pause the migration.
class Stop < Base
# :nocov:
def log_info?
true
end
2022-08-27 11:52:29 +05:30
def stop?
true
end
2022-08-13 15:12:31 +05:30
# :nocov:
end
# A Signals::Normal indicates normal system state: We carry on with the migration
# and may even attempt to optimize its throughput etc.
class Normal < Base; end
# When given an Signals::Unknown, something unexpected happened while
# we evaluated system indicators.
class Unknown < Base
# :nocov:
def log_info?
true
end
# :nocov:
end
# No signal could be determined, e.g. because the indicator
# was disabled.
class NotAvailable < Base; end
end
end
end
end
end