Skip to content
Snippets Groups Projects
Commit f78af0fc authored by Oswaldo Ferreir's avatar Oswaldo Ferreir
Browse files

Add cop to encourage idempotent Sidekiq workers

This commit's goal is to add a cop (Scalability::IdempotentWorker)
that will catch all workers that don't call idempotent! in its scope.

Calling it will label the worker as idempotent, which will end up in
our Sidekiq logs for further visibility.

This also introduces a shared example and a perform_multiple helper
method for executing jobs multiple times through unit tests.

Also in this commit we set an example in an already idempotent worker
ExpireJobCacheWorker. For this worker we call idempotent! in its
scope and add tests with the new test helpers.
parent f378b397
No related branches found
No related tags found
No related merge requests found
Showing
with 199 additions and 19 deletions
# frozen_string_literal: true
 
class AdminEmailWorker
class AdminEmailWorker # rubocop:disable Scalability/IdempotentWorker
include ApplicationWorker
# rubocop:disable Scalability/CronWorkerContext
# This worker does not perform work scoped to a context
Loading
Loading
This diff is collapsed.
# frozen_string_literal: true
 
class ArchiveTraceWorker
class ArchiveTraceWorker # rubocop:disable Scalability/IdempotentWorker
include ApplicationWorker
include PipelineBackgroundQueue
 
Loading
Loading
# frozen_string_literal: true
 
class AuthorizedProjectsWorker
class AuthorizedProjectsWorker # rubocop:disable Scalability/IdempotentWorker
include ApplicationWorker
prepend WaitableWorker
 
Loading
Loading
# frozen_string_literal: true
 
module AutoDevops
class DisableWorker
class DisableWorker # rubocop:disable Scalability/IdempotentWorker
include ApplicationWorker
include AutoDevopsQueue
 
Loading
Loading
# frozen_string_literal: true
 
class AutoMergeProcessWorker
class AutoMergeProcessWorker # rubocop:disable Scalability/IdempotentWorker
include ApplicationWorker
 
queue_namespace :auto_merge
Loading
Loading
# frozen_string_literal: true
 
class BackgroundMigrationWorker
class BackgroundMigrationWorker # rubocop:disable Scalability/IdempotentWorker
include ApplicationWorker
 
feature_category_not_owned!
Loading
Loading
# frozen_string_literal: true
 
class BuildCoverageWorker
class BuildCoverageWorker # rubocop:disable Scalability/IdempotentWorker
include ApplicationWorker
include PipelineQueue
 
Loading
Loading
# frozen_string_literal: true
 
class BuildFinishedWorker
class BuildFinishedWorker # rubocop:disable Scalability/IdempotentWorker
include ApplicationWorker
include PipelineQueue
 
Loading
Loading
# frozen_string_literal: true
 
class BuildHooksWorker
class BuildHooksWorker # rubocop:disable Scalability/IdempotentWorker
include ApplicationWorker
include PipelineQueue
 
Loading
Loading
# frozen_string_literal: true
 
class BuildQueueWorker
class BuildQueueWorker # rubocop:disable Scalability/IdempotentWorker
include ApplicationWorker
include PipelineQueue
 
Loading
Loading
# frozen_string_literal: true
 
class BuildSuccessWorker
class BuildSuccessWorker # rubocop:disable Scalability/IdempotentWorker
include ApplicationWorker
include PipelineQueue
 
Loading
Loading
# frozen_string_literal: true
 
class BuildTraceSectionsWorker
class BuildTraceSectionsWorker # rubocop:disable Scalability/IdempotentWorker
include ApplicationWorker
include PipelineQueue
 
Loading
Loading
# frozen_string_literal: true
 
module Chaos
class CpuSpinWorker
class CpuSpinWorker # rubocop:disable Scalability/IdempotentWorker
include ApplicationWorker
include ChaosQueue
 
Loading
Loading
# frozen_string_literal: true
 
module Chaos
class DbSpinWorker
class DbSpinWorker # rubocop:disable Scalability/IdempotentWorker
include ApplicationWorker
include ChaosQueue
 
Loading
Loading
# frozen_string_literal: true
 
module Chaos
class KillWorker
class KillWorker # rubocop:disable Scalability/IdempotentWorker
include ApplicationWorker
include ChaosQueue
 
Loading
Loading
# frozen_string_literal: true
 
module Chaos
class LeakMemWorker
class LeakMemWorker # rubocop:disable Scalability/IdempotentWorker
include ApplicationWorker
include ChaosQueue
 
Loading
Loading
# frozen_string_literal: true
 
module Chaos
class SleepWorker
class SleepWorker # rubocop:disable Scalability/IdempotentWorker
include ApplicationWorker
include ChaosQueue
 
Loading
Loading
# frozen_string_literal: true
 
class ChatNotificationWorker
class ChatNotificationWorker # rubocop:disable Scalability/IdempotentWorker
include ApplicationWorker
 
TimeoutExceeded = Class.new(StandardError)
Loading
Loading
# frozen_string_literal: true
 
module Ci
class ArchiveTracesCronWorker
class ArchiveTracesCronWorker # rubocop:disable Scalability/IdempotentWorker
include ApplicationWorker
include CronjobQueue # rubocop:disable Scalability/CronWorkerContext
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment