Class: PersonalAccessTokens::ExpiringWorker

Inherits:
Object
  • Object
show all
Includes:
ApplicationWorker, CronjobQueue, Gitlab::Utils::StrongMemoize
Defined in:
app/workers/personal_access_tokens/expiring_worker.rb

Overview

rubocop:disable Scalability/IdempotentWorker

Constant Summary collapse

MAX_TOKENS =
100
MAX_RUNTIME =
3.minutes
REQUEUE_DELAY =
2.minutes
BATCH_SIZE =

For the worker is timing out with a bigger batch size gitlab.com/gitlab-org/gitlab/-/issues/432518

100

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

Class Method Summary collapse

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

Class Method Details

.batch_sizeObject

allows easier stubbing in specs



23
24
25
# File 'app/workers/personal_access_tokens/expiring_worker.rb', line 23

def self.batch_size
  BATCH_SIZE
end

Instance Method Details

#perform(*args) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/workers/personal_access_tokens/expiring_worker.rb', line 27

def perform(*args)
  @runtime_limiter = Gitlab::Metrics::RuntimeLimiter.new(MAX_RUNTIME)
  notification_intervals.each do |interval|
    process_user_tokens(interval)
    break if over_time?

    process_project_bot_tokens(interval)
    break if over_time?
  end

  self.class.perform_in(REQUEUE_DELAY, *args) if over_time?
end