diff options
author | Phil Hughes <me@iamphill.com> | 2016-10-26 08:47:09 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-10-26 08:47:09 +0100 |
commit | a2eff1a8e55b4bf513d3d752fcd6477595813dc2 (patch) | |
tree | e7d5e3e097ef85b871c7ab5b4673e6903c294144 /doc/development/sidekiq_style_guide.md | |
parent | 13f170fc5d182da78c3d0a7a0885628f59420ea0 (diff) | |
parent | 3d174c7198f103cdedd7c7ffb7678aff1dd4de33 (diff) | |
download | gitlab-ce-issue-board-sidebar.tar.gz |
Merge branch 'master' into issue-board-sidebarissue-board-sidebar
Diffstat (limited to 'doc/development/sidekiq_style_guide.md')
-rw-r--r-- | doc/development/sidekiq_style_guide.md | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/doc/development/sidekiq_style_guide.md b/doc/development/sidekiq_style_guide.md new file mode 100644 index 00000000000..e3a20f29a09 --- /dev/null +++ b/doc/development/sidekiq_style_guide.md @@ -0,0 +1,38 @@ +# Sidekiq Style Guide + +This document outlines various guidelines that should be followed when adding or +modifying Sidekiq workers. + +## Default Queue + +Use of the "default" queue is not allowed. Every worker should use a queue that +matches the worker's purpose the closest. For example, workers that are to be +executed periodically should use the "cronjob" queue. + +A list of all available queues can be found in `config/sidekiq_queues.yml`. + +## Dedicated Queues + +Most workers should use their own queue. To ease this process a worker can +include the `DedicatedSidekiqQueue` concern as follows: + +```ruby +class ProcessSomethingWorker + include Sidekiq::Worker + include DedicatedSidekiqQueue +end +``` + +This will set the queue name based on the class' name, minus the `Worker` +suffix. In the above example this would lead to the queue being +`process_something`. + +In some cases multiple workers do use the same queue. For example, the various +workers for updating CI pipelines all use the `pipeline` queue. Adding workers +to existing queues should be done with care, as adding more workers can lead to +slow jobs blocking work (even for different jobs) on the shared queue. + +## Tests + +Each Sidekiq worker must be tested using RSpec, just like any other class. These +tests should be placed in `spec/workers`. |