summaryrefslogtreecommitdiff
path: root/doc/development/sidekiq/compatibility_across_updates.md
diff options
context:
space:
mode:
Diffstat (limited to 'doc/development/sidekiq/compatibility_across_updates.md')
-rw-r--r--doc/development/sidekiq/compatibility_across_updates.md150
1 files changed, 75 insertions, 75 deletions
diff --git a/doc/development/sidekiq/compatibility_across_updates.md b/doc/development/sidekiq/compatibility_across_updates.md
index b417a099228..97663b0b41c 100644
--- a/doc/development/sidekiq/compatibility_across_updates.md
+++ b/doc/development/sidekiq/compatibility_across_updates.md
@@ -46,30 +46,30 @@ following example deprecates and then removes `arg2` from the `perform_async` me
1. Provide a default value (usually `nil`) and use a comment to mark the
argument as deprecated in the coming minor release. (Release M)
- ```ruby
- class ExampleWorker
- # Keep arg2 parameter for backwards compatibility.
- def perform(object_id, arg1, arg2 = nil)
- # ...
- end
- end
- ```
+ ```ruby
+ class ExampleWorker
+ # Keep arg2 parameter for backwards compatibility.
+ def perform(object_id, arg1, arg2 = nil)
+ # ...
+ end
+ end
+ ```
1. One minor release later, stop using the argument in `perform_async`. (Release M+1)
- ```ruby
- ExampleWorker.perform_async(object_id, arg1)
- ```
+ ```ruby
+ ExampleWorker.perform_async(object_id, arg1)
+ ```
1. At the next major release, remove the value from the worker class. (Next major release)
- ```ruby
- class ExampleWorker
- def perform(object_id, arg1)
- # ...
- end
- end
- ```
+ ```ruby
+ class ExampleWorker
+ def perform(object_id, arg1)
+ # ...
+ end
+ end
+ ```
### Add an argument
@@ -84,29 +84,29 @@ This approach requires multiple releases.
1. Add the argument to the worker with a default value (Release M).
- ```ruby
- class ExampleWorker
- def perform(object_id, new_arg = nil)
- # ...
- end
- end
- ```
+ ```ruby
+ class ExampleWorker
+ def perform(object_id, new_arg = nil)
+ # ...
+ end
+ end
+ ```
1. Add the new argument to all the invocations of the worker (Release M+1).
- ```ruby
- ExampleWorker.perform_async(object_id, new_arg)
- ```
+ ```ruby
+ ExampleWorker.perform_async(object_id, new_arg)
+ ```
1. Remove the default value (Release M+2).
- ```ruby
- class ExampleWorker
- def perform(object_id, new_arg)
- # ...
- end
- end
- ```
+ ```ruby
+ class ExampleWorker
+ def perform(object_id, new_arg)
+ # ...
+ end
+ end
+ ```
#### Parameter hash
@@ -115,13 +115,13 @@ uses a parameter hash.
1. Use a parameter hash in the worker to allow future flexibility.
- ```ruby
- class ExampleWorker
- def perform(object_id, params = {})
- # ...
- end
- end
- ```
+ ```ruby
+ class ExampleWorker
+ def perform(object_id, params = {})
+ # ...
+ end
+ end
+ ```
## Removing worker classes
@@ -131,54 +131,54 @@ To remove a worker class, follow these steps over two minor releases:
1. Remove any code that enqueues the jobs.
- For example, if there is a UI component or an API endpoint that a user can interact with that results in the worker instance getting enqueued, make sure those surface areas are either removed or updated in a way that the worker instance is no longer enqueued.
+ For example, if there is a UI component or an API endpoint that a user can interact with that results in the worker instance getting enqueued, make sure those surface areas are either removed or updated in a way that the worker instance is no longer enqueued.
- This ensures that instances related to the worker class are no longer being enqueued.
+ This ensures that instances related to the worker class are no longer being enqueued.
1. Ensure both the frontend and backend code no longer relies on any of the work that used to be done by the worker.
1. In the relevant worker classes, replace the contents of the `perform` method with a no-op, while keeping any arguments in tact.
- For example, if you're working with the following `ExampleWorker`:
+ For example, if you're working with the following `ExampleWorker`:
- ```ruby
- class ExampleWorker
- def perform(object_id)
- SomeService.run!(object_id)
- end
- end
- ```
+ ```ruby
+ class ExampleWorker
+ def perform(object_id)
+ SomeService.run!(object_id)
+ end
+ end
+ ```
- Implementing the no-op might look like this:
+ Implementing the no-op might look like this:
- ```ruby
- class ExampleWorker
- def perform(object_id); end
- end
- ```
+ ```ruby
+ class ExampleWorker
+ def perform(object_id); end
+ end
+ ```
- By implementing this no-op, you can avoid unnecessary cycles once any deprecated jobs that are still enqueued eventually get processed.
+ By implementing this no-op, you can avoid unnecessary cycles once any deprecated jobs that are still enqueued eventually get processed.
### In a subsequent, separate minor release
1. Delete the worker class file and follow the guidance in our [Sidekiq queues documentation](../sidekiq/index.md#sidekiq-queues) around running Rake tasks to regenerate/update related files.
1. Add a migration (not a post-deployment migration) that uses `sidekiq_remove_jobs`:
- ```ruby
- class RemoveMyDeprecatedWorkersJobInstances < Gitlab::Database::Migration[2.0]
- DEPRECATED_JOB_CLASSES = %w[
- MyDeprecatedWorkerOne
- MyDeprecatedWorkerTwo
- ]
-
- def up
- sidekiq_remove_jobs(job_klasses: DEPRECATED_JOB_CLASSES)
- end
-
- def down
- # This migration removes any instances of deprecated workers and cannot be undone.
- end
- end
- ```
+ ```ruby
+ class RemoveMyDeprecatedWorkersJobInstances < Gitlab::Database::Migration[2.0]
+ DEPRECATED_JOB_CLASSES = %w[
+ MyDeprecatedWorkerOne
+ MyDeprecatedWorkerTwo
+ ]
+
+ def up
+ sidekiq_remove_jobs(job_klasses: DEPRECATED_JOB_CLASSES)
+ end
+
+ def down
+ # This migration removes any instances of deprecated workers and cannot be undone.
+ end
+ end
+ ```
## Renaming queues