Module: Gitlab::SidekiqMiddleware

Defined in:
lib/gitlab/sidekiq_middleware.rb,
lib/gitlab/sidekiq_middleware/metrics.rb,
lib/gitlab/sidekiq_middleware/monitor.rb,
lib/gitlab/sidekiq_middleware/batch_loader.rb,
lib/gitlab/sidekiq_middleware/memory_killer.rb,
lib/gitlab/sidekiq_middleware/client_metrics.rb,
lib/gitlab/sidekiq_middleware/server_metrics.rb,
lib/gitlab/sidekiq_middleware/worker_context.rb,
lib/gitlab/sidekiq_middleware/arguments_logger.rb,
lib/gitlab/sidekiq_middleware/admin_mode/client.rb,
lib/gitlab/sidekiq_middleware/admin_mode/server.rb,
lib/gitlab/sidekiq_middleware/duplicate_jobs/client.rb,
lib/gitlab/sidekiq_middleware/duplicate_jobs/server.rb,
lib/gitlab/sidekiq_middleware/worker_context/client.rb,
lib/gitlab/sidekiq_middleware/worker_context/server.rb,
lib/gitlab/sidekiq_middleware/instrumentation_logger.rb,
lib/gitlab/sidekiq_middleware/extra_done_log_metadata.rb,
lib/gitlab/sidekiq_middleware/request_store_middleware.rb,
lib/gitlab/sidekiq_middleware/duplicate_jobs/strategies.rb,
lib/gitlab/sidekiq_middleware/duplicate_jobs/duplicate_job.rb,
lib/gitlab/sidekiq_middleware/duplicate_jobs/strategies/until_executing.rb

Overview

The SidekiqMiddleware class is responsible for configuring the middleware stacks used in the client and server middlewares

Defined Under Namespace

Modules: AdminMode, DuplicateJobs, WorkerContext Classes: ArgumentsLogger, BatchLoader, ClientMetrics, ExtraDoneLogMetadata, InstrumentationLogger, MemoryKiller, Metrics, Monitor, RequestStoreMiddleware, ServerMetrics

Class Method Summary collapse

Class Method Details

.client_configuratorObject

The result of this method should be passed to Sidekiq's `config.client_middleware` method eg: `config.client_middleware(&Gitlab::SidekiqMiddleware.client_configurator)`


32
33
34
35
36
37
38
39
40
41
# File 'lib/gitlab/sidekiq_middleware.rb', line 32

def self.client_configurator
  lambda do |chain|
    chain.add ::Gitlab::SidekiqMiddleware::WorkerContext::Client # needs to be before the Labkit middleware
    chain.add ::Labkit::Middleware::Sidekiq::Client
    chain.add ::Gitlab::SidekiqMiddleware::DuplicateJobs::Client
    chain.add ::Gitlab::SidekiqStatus::ClientMiddleware
    chain.add ::Gitlab::SidekiqMiddleware::AdminMode::Client
    chain.add ::Gitlab::SidekiqMiddleware::ClientMetrics
  end
end

.server_configurator(metrics: true, arguments_logger: true, memory_killer: true) ⇒ Object

The result of this method should be passed to Sidekiq's `config.server_middleware` method eg: `config.server_middleware(&Gitlab::SidekiqMiddleware.server_configurator)`


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/gitlab/sidekiq_middleware.rb', line 10

def self.server_configurator(metrics: true, arguments_logger: true, memory_killer: true)
  lambda do |chain|
    chain.add ::Gitlab::SidekiqMiddleware::Monitor
    chain.add ::Gitlab::SidekiqMiddleware::ServerMetrics if metrics
    chain.add ::Gitlab::SidekiqMiddleware::ArgumentsLogger if arguments_logger
    chain.add ::Gitlab::SidekiqMiddleware::MemoryKiller if memory_killer
    chain.add ::Gitlab::SidekiqMiddleware::RequestStoreMiddleware
    chain.add ::Gitlab::SidekiqMiddleware::ExtraDoneLogMetadata
    chain.add ::Gitlab::SidekiqMiddleware::BatchLoader
    chain.add ::Labkit::Middleware::Sidekiq::Server
    chain.add ::Gitlab::SidekiqMiddleware::InstrumentationLogger
    chain.add ::Gitlab::SidekiqMiddleware::AdminMode::Server
    chain.add ::Gitlab::SidekiqVersioning::Middleware
    chain.add ::Gitlab::SidekiqStatus::ServerMiddleware
    chain.add ::Gitlab::SidekiqMiddleware::WorkerContext::Server
    chain.add ::Gitlab::SidekiqMiddleware::DuplicateJobs::Server
  end
end