debian-mirror-gitlab/lib/gitlab/sidekiq_middleware.rb

40 lines
1.8 KiB
Ruby
Raw Normal View History

2020-01-01 13:55:28 +05:30
# frozen_string_literal: true
module Gitlab
# The SidekiqMiddleware class is responsible for configuring the
# middleware stacks used in the client and server middlewares
module SidekiqMiddleware
# The result of this method should be passed to
# Sidekiq's `config.server_middleware` method
# eg: `config.server_middleware(&Gitlab::SidekiqMiddleware.server_configurator)`
def self.server_configurator(metrics: true, arguments_logger: true, memory_killer: true, request_store: true)
lambda do |chain|
chain.add Gitlab::SidekiqMiddleware::Monitor
2020-03-09 13:42:32 +05:30
chain.add Gitlab::SidekiqMiddleware::ServerMetrics if metrics
2020-01-01 13:55:28 +05:30
chain.add Gitlab::SidekiqMiddleware::ArgumentsLogger if arguments_logger
chain.add Gitlab::SidekiqMiddleware::MemoryKiller if memory_killer
chain.add Gitlab::SidekiqMiddleware::RequestStoreMiddleware if request_store
chain.add Gitlab::SidekiqMiddleware::BatchLoader
2020-03-09 13:42:32 +05:30
chain.add Labkit::Middleware::Sidekiq::Server
2020-01-01 13:55:28 +05:30
chain.add Gitlab::SidekiqMiddleware::InstrumentationLogger
2020-03-09 13:42:32 +05:30
chain.add Gitlab::SidekiqMiddleware::AdminMode::Server
2020-01-01 13:55:28 +05:30
chain.add Gitlab::SidekiqStatus::ServerMiddleware
2020-03-09 13:42:32 +05:30
chain.add Gitlab::SidekiqMiddleware::WorkerContext::Server
2020-01-01 13:55:28 +05:30
end
end
# The result of this method should be passed to
# Sidekiq's `config.client_middleware` method
# eg: `config.client_middleware(&Gitlab::SidekiqMiddleware.client_configurator)`
def self.client_configurator
lambda do |chain|
chain.add Gitlab::SidekiqStatus::ClientMiddleware
2020-03-09 13:42:32 +05:30
chain.add Gitlab::SidekiqMiddleware::ClientMetrics
chain.add Gitlab::SidekiqMiddleware::WorkerContext::Client # needs to be before the Labkit middleware
chain.add Labkit::Middleware::Sidekiq::Client
chain.add Gitlab::SidekiqMiddleware::AdminMode::Client
2020-01-01 13:55:28 +05:30
end
end
end
end