Class: Import::PlaceholderUserCleanupWorker

Inherits:
Object
  • Object
show all
Includes:
ApplicationWorker, CronjobQueue
Defined in:
app/workers/import/placeholder_user_cleanup_worker.rb

Constant Summary collapse

MAX_ATTEMPTS =
15

Constants included from ApplicationWorker

ApplicationWorker::LOGGING_EXTRA_KEY, ApplicationWorker::SAFE_PUSH_BULK_LIMIT

Constants included from Gitlab::Loggable

Gitlab::Loggable::ANONYMOUS

Constants included from WorkerAttributes

WorkerAttributes::DEFAULT_CONCURRENCY_LIMIT_PERCENTAGE_BY_URGENCY, WorkerAttributes::DEFAULT_DATA_CONSISTENCY, WorkerAttributes::DEFAULT_DATA_CONSISTENCY_PER_DB, WorkerAttributes::DEFAULT_DEFER_DELAY, WorkerAttributes::LOAD_BALANCED_DATA_CONSISTENCIES, WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_DATA_CONSISTENCIES, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES

Instance Method Summary collapse

Methods included from Gitlab::Loggable

#build_structured_payload

Methods included from Gitlab::SidekiqVersioning::Worker

#job_version

Methods included from WorkerContext

#with_context

Instance Method Details

#log_max_attempts_warning(detail) ⇒ Object



29
30
31
32
33
34
35
# File 'app/workers/import/placeholder_user_cleanup_worker.rb', line 29

def log_max_attempts_warning(detail)
  ::Import::Framework::Logger.warn(
    message: "Maximum deletion attempts (#{MAX_ATTEMPTS}) reached for deletion of placeholder user." \
      "Making final deletion attempt.",
    placeholder_user_id: detail.placeholder_user_id
  )
end

#max_attempts_reached?(detail) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'app/workers/import/placeholder_user_cleanup_worker.rb', line 25

def max_attempts_reached?(detail)
  detail.deletion_attempts + 1 >= MAX_ATTEMPTS
end

#performObject



14
15
16
17
18
19
20
21
22
23
# File 'app/workers/import/placeholder_user_cleanup_worker.rb', line 14

def perform
  Import::PlaceholderUserDetail.eligible_for_deletion.find_each.with_index do |detail, index|
    detail.increment_deletion_attempt
    log_max_attempts_warning(detail) if max_attempts_reached?(detail)

    delay = index * 1.second

    Import::DeletePlaceholderUserWorker.perform_in(delay, detail.placeholder_user_id)
  end
end