summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/api/groups.rb2
-rw-r--r--lib/api/helpers/runner.rb2
-rw-r--r--lib/api/runner.rb2
-rw-r--r--lib/email_template_interceptor.rb2
-rw-r--r--lib/gitlab/asciidoc.rb2
-rw-r--r--lib/gitlab/auth.rb2
-rw-r--r--lib/gitlab/auth/unique_ips_limiter.rb2
-rw-r--r--lib/gitlab/current_settings.rb110
-rw-r--r--lib/gitlab/git/storage/circuit_breaker_settings.rb2
-rw-r--r--lib/gitlab/github_import/project_creator.rb2
-rw-r--r--lib/gitlab/gon_helper.rb2
-rw-r--r--lib/gitlab/metrics/influx_db.rb18
-rw-r--r--lib/gitlab/metrics/prometheus.rb4
-rw-r--r--lib/gitlab/performance_bar.rb2
-rw-r--r--lib/gitlab/polling_interval.rb2
-rw-r--r--lib/gitlab/protocol_access.rb2
-rw-r--r--lib/gitlab/recaptcha.rb2
-rw-r--r--lib/gitlab/sentry.rb2
-rw-r--r--lib/gitlab/sidekiq_throttler.rb4
-rw-r--r--lib/gitlab/usage_data.rb2
-rw-r--r--lib/gitlab/visibility_level.rb2
-rw-r--r--lib/tasks/import.rake2
22 files changed, 88 insertions, 84 deletions
diff --git a/lib/api/groups.rb b/lib/api/groups.rb
index e817dcbbc4b..2bbc72c8666 100644
--- a/lib/api/groups.rb
+++ b/lib/api/groups.rb
@@ -10,7 +10,7 @@ module API
optional :visibility, type: String,
values: Gitlab::VisibilityLevel.string_values,
default: Gitlab::VisibilityLevel.string_level(
- Gitlab::CurrentSettings.current_application_settings.default_group_visibility),
+ Gitlab::CurrentSettings.default_group_visibility),
desc: 'The visibility of the group'
optional :lfs_enabled, type: Boolean, desc: 'Enable/disable LFS for the projects in this group'
optional :request_access_enabled, type: Boolean, desc: 'Allow users to request member access'
diff --git a/lib/api/helpers/runner.rb b/lib/api/helpers/runner.rb
index 282af32ca94..74488cab146 100644
--- a/lib/api/helpers/runner.rb
+++ b/lib/api/helpers/runner.rb
@@ -1,7 +1,7 @@
module API
module Helpers
module Runner
- include Gitlab::CurrentSettings
+ # include Gitlab::CurrentSettings
JOB_TOKEN_HEADER = 'HTTP_JOB_TOKEN'.freeze
JOB_TOKEN_PARAM = :token
diff --git a/lib/api/runner.rb b/lib/api/runner.rb
index a3987c560dd..50b42668063 100644
--- a/lib/api/runner.rb
+++ b/lib/api/runner.rb
@@ -225,7 +225,7 @@ module API
job.artifacts_file = artifacts
job.artifacts_metadata = metadata
job.artifacts_expire_in = params['expire_in'] ||
- Gitlab::CurrentSettings.current_application_settings.default_artifacts_expire_in
+ Gitlab::CurrentSettings.default_artifacts_expire_in
if job.save
present job, with: Entities::JobRequest::Response
diff --git a/lib/email_template_interceptor.rb b/lib/email_template_interceptor.rb
index f2bf3d0fb2b..a069bdfc8a2 100644
--- a/lib/email_template_interceptor.rb
+++ b/lib/email_template_interceptor.rb
@@ -1,6 +1,6 @@
# Read about interceptors in http://guides.rubyonrails.org/action_mailer_basics.html#intercepting-emails
class EmailTemplateInterceptor
- extend Gitlab::CurrentSettings
+ # # extend Gitlab::CurrentSettings
def self.delivering_email(message)
# Remove HTML part if HTML emails are disabled.
diff --git a/lib/gitlab/asciidoc.rb b/lib/gitlab/asciidoc.rb
index cead1c7eacd..4bd600de1aa 100644
--- a/lib/gitlab/asciidoc.rb
+++ b/lib/gitlab/asciidoc.rb
@@ -6,7 +6,7 @@ module Gitlab
# Parser/renderer for the AsciiDoc format that uses Asciidoctor and filters
# the resulting HTML through HTML pipeline filters.
module Asciidoc
- extend Gitlab::CurrentSettings
+ # extend Gitlab::CurrentSettings
DEFAULT_ADOC_ATTRS = [
'showtitle', 'idprefix=user-content-', 'idseparator=-', 'env=gitlab',
diff --git a/lib/gitlab/auth.rb b/lib/gitlab/auth.rb
index 87aeb76b66a..76decab7d29 100644
--- a/lib/gitlab/auth.rb
+++ b/lib/gitlab/auth.rb
@@ -14,7 +14,7 @@ module Gitlab
DEFAULT_SCOPES = [:api].freeze
class << self
- include Gitlab::CurrentSettings
+ # include Gitlab::CurrentSettings
def find_for_git_client(login, password, project:, ip:)
raise "Must provide an IP for rate limiting" if ip.nil?
diff --git a/lib/gitlab/auth/unique_ips_limiter.rb b/lib/gitlab/auth/unique_ips_limiter.rb
index baa1f802d8a..be5bad2606a 100644
--- a/lib/gitlab/auth/unique_ips_limiter.rb
+++ b/lib/gitlab/auth/unique_ips_limiter.rb
@@ -20,7 +20,7 @@ module Gitlab
end
def config
- Gitlab::CurrentSettings.current_application_settings
+ Gitlab::CurrentSettings
end
def update_and_return_ips_count(user_id, ip)
diff --git a/lib/gitlab/current_settings.rb b/lib/gitlab/current_settings.rb
index 642f0944354..8a48e636125 100644
--- a/lib/gitlab/current_settings.rb
+++ b/lib/gitlab/current_settings.rb
@@ -1,73 +1,79 @@
module Gitlab
- module CurrentSettings
- extend self
+ class CurrentSettings
+ class << self
+ def method_missing(method_sym, *arguments, &block)
+ Gitlab::CurrentSettings.fetch_settings.send(method_sym, *arguments)
+ end
- def current_application_settings
- if RequestStore.active?
- RequestStore.fetch(:current_application_settings) { ensure_application_settings! }
- else
- ensure_application_settings!
+ def fetch_settings
+ if RequestStore.active?
+ RequestStore.fetch(:current_application_settings) { ensure_application_settings! }
+ else
+ ensure_application_settings!
+ end
end
- end
- delegate :sidekiq_throttling_enabled?, to: :current_application_settings
+ def ensure_application_settings!
+ return in_memory_application_settings if ENV['IN_MEMORY_APPLICATION_SETTINGS'] == 'true'
- def fake_application_settings(defaults = ::ApplicationSetting.defaults)
- FakeApplicationSettings.new(defaults)
- end
+ cached_application_settings || uncached_application_settings
+ end
- private
+ def cached_application_settings
+ begin
+ ::ApplicationSetting.cached
+ rescue ::Redis::BaseError, ::Errno::ENOENT, ::Errno::EADDRNOTAVAIL
+ # In case Redis isn't running or the Redis UNIX socket file is not available
+ end
+ end
- def ensure_application_settings!
- return in_memory_application_settings if ENV['IN_MEMORY_APPLICATION_SETTINGS'] == 'true'
+ def uncached_application_settings
+ return fake_application_settings unless connect_to_db?
- cached_application_settings || uncached_application_settings
- end
+ db_settings = ::ApplicationSetting.current
- def cached_application_settings
- begin
- ::ApplicationSetting.cached
- rescue ::Redis::BaseError, ::Errno::ENOENT, ::Errno::EADDRNOTAVAIL
- # In case Redis isn't running or the Redis UNIX socket file is not available
- end
- end
+ # If there are pending migrations, it's possible there are columns that
+ # need to be added to the application settings. To prevent Rake tasks
+ # and other callers from failing, use any loaded settings and return
+ # defaults for missing columns.
+ if ActiveRecord::Migrator.needs_migration?
+ defaults = ::ApplicationSetting.defaults
+ defaults.merge!(db_settings.attributes.symbolize_keys) if db_settings.present?
+ return fake_application_settings(defaults)
+ end
- def uncached_application_settings
- return fake_application_settings unless connect_to_db?
+ return db_settings if db_settings.present?
- db_settings = ::ApplicationSetting.current
+ ::ApplicationSetting.create_from_defaults || in_memory_application_settings
+ end
- # If there are pending migrations, it's possible there are columns that
- # need to be added to the application settings. To prevent Rake tasks
- # and other callers from failing, use any loaded settings and return
- # defaults for missing columns.
- if ActiveRecord::Migrator.needs_migration?
- defaults = ::ApplicationSetting.defaults
- defaults.merge!(db_settings.attributes.symbolize_keys) if db_settings.present?
- return fake_application_settings(defaults)
+ def in_memory_application_settings
+ @in_memory_application_settings ||= ::ApplicationSetting.new(::ApplicationSetting.defaults)
+ rescue ActiveRecord::StatementInvalid, ActiveRecord::UnknownAttributeError
+ # In case migrations the application_settings table is not created yet,
+ # we fallback to a simple OpenStruct
+ fake_application_settings
end
- return db_settings if db_settings.present?
+ def connect_to_db?
+ # When the DBMS is not available, an exception (e.g. PG::ConnectionBad) is raised
+ active_db_connection = ActiveRecord::Base.connection.active? rescue false
- ::ApplicationSetting.create_from_defaults || in_memory_application_settings
+ active_db_connection &&
+ ActiveRecord::Base.connection.table_exists?('application_settings')
+ rescue ActiveRecord::NoDatabaseError
+ false
+ end
end
+ #extend self
- def in_memory_application_settings
- @in_memory_application_settings ||= ::ApplicationSetting.new(::ApplicationSetting.defaults)
- rescue ActiveRecord::StatementInvalid, ActiveRecord::UnknownAttributeError
- # In case migrations the application_settings table is not created yet,
- # we fallback to a simple OpenStruct
- fake_application_settings
- end
+ # def current_application_settings
+ # end
- def connect_to_db?
- # When the DBMS is not available, an exception (e.g. PG::ConnectionBad) is raised
- active_db_connection = ActiveRecord::Base.connection.active? rescue false
+ #delegate :sidekiq_throttling_enabled?, to: :current_application_settings
- active_db_connection &&
- ActiveRecord::Base.connection.table_exists?('application_settings')
- rescue ActiveRecord::NoDatabaseError
- false
- end
+ # def fake_application_settings(defaults = ::ApplicationSetting.defaults)
+ # FakeApplicationSettings.new(defaults)
+ # end
end
end
diff --git a/lib/gitlab/git/storage/circuit_breaker_settings.rb b/lib/gitlab/git/storage/circuit_breaker_settings.rb
index d2313fe7c1b..9e306eaaa09 100644
--- a/lib/gitlab/git/storage/circuit_breaker_settings.rb
+++ b/lib/gitlab/git/storage/circuit_breaker_settings.rb
@@ -21,7 +21,7 @@ module Gitlab
private
def application_settings
- Gitlab::CurrentSettings.current_application_settings
+ Gitlab::CurrentSettings
end
end
end
diff --git a/lib/gitlab/github_import/project_creator.rb b/lib/gitlab/github_import/project_creator.rb
index a55adc9b1c8..fa99fbee6c3 100644
--- a/lib/gitlab/github_import/project_creator.rb
+++ b/lib/gitlab/github_import/project_creator.rb
@@ -1,7 +1,7 @@
module Gitlab
module GithubImport
class ProjectCreator
- include Gitlab::CurrentSettings
+ # include Gitlab::CurrentSettings
attr_reader :repo, :name, :namespace, :current_user, :session_data, :type
diff --git a/lib/gitlab/gon_helper.rb b/lib/gitlab/gon_helper.rb
index 3a666c2268b..535f7a8002b 100644
--- a/lib/gitlab/gon_helper.rb
+++ b/lib/gitlab/gon_helper.rb
@@ -3,7 +3,7 @@
module Gitlab
module GonHelper
include WebpackHelper
- include Gitlab::CurrentSettings
+ # include Gitlab::CurrentSettings
def add_gon_variables
gon.api_version = 'v4'
diff --git a/lib/gitlab/metrics/influx_db.rb b/lib/gitlab/metrics/influx_db.rb
index 7b06bb953aa..9ca20d56699 100644
--- a/lib/gitlab/metrics/influx_db.rb
+++ b/lib/gitlab/metrics/influx_db.rb
@@ -1,7 +1,7 @@
module Gitlab
module Metrics
module InfluxDb
- include Gitlab::CurrentSettings
+ # include Gitlab::CurrentSettings
extend self
MUTEX = Mutex.new
@@ -17,14 +17,14 @@ module Gitlab
def settings
@settings ||= {
- enabled: current_application_settings[:metrics_enabled],
- pool_size: current_application_settings[:metrics_pool_size],
- timeout: current_application_settings[:metrics_timeout],
- method_call_threshold: current_application_settings[:metrics_method_call_threshold],
- host: current_application_settings[:metrics_host],
- port: current_application_settings[:metrics_port],
- sample_interval: current_application_settings[:metrics_sample_interval] || 15,
- packet_size: current_application_settings[:metrics_packet_size] || 1
+ enabled: Gitlab::CurrentSettings.metrics_enabled,
+ pool_size: Gitlab::CurrentSettings.metrics_pool_size,
+ timeout: Gitlab::CurrentSettings.metrics_timeout,
+ method_call_threshold: Gitlab::CurrentSettings.metrics_method_call_threshold,
+ host: Gitlab::CurrentSettings.metrics_host,
+ port: Gitlab::CurrentSettings.metrics_port,
+ sample_interval: Gitlab::CurrentSettings.metrics_sample_interval || 15,
+ packet_size: Gitlab::CurrentSettings.metrics_packet_size || 1
}
end
diff --git a/lib/gitlab/metrics/prometheus.rb b/lib/gitlab/metrics/prometheus.rb
index 460dab47276..a50f7aec5d8 100644
--- a/lib/gitlab/metrics/prometheus.rb
+++ b/lib/gitlab/metrics/prometheus.rb
@@ -3,8 +3,6 @@ require 'prometheus/client'
module Gitlab
module Metrics
module Prometheus
- include Gitlab::CurrentSettings
-
def metrics_folder_present?
multiprocess_files_dir = ::Prometheus::Client.configuration.multiprocess_files_dir
@@ -50,7 +48,7 @@ module Gitlab
private
def prometheus_metrics_enabled_unmemoized
- metrics_folder_present? && current_application_settings[:prometheus_metrics_enabled] || false
+ metrics_folder_present? && Gitlab::CurrentSettings.prometheus_metrics_enabled || false
end
end
end
diff --git a/lib/gitlab/performance_bar.rb b/lib/gitlab/performance_bar.rb
index e73245b82c1..b7c04a05b90 100644
--- a/lib/gitlab/performance_bar.rb
+++ b/lib/gitlab/performance_bar.rb
@@ -1,6 +1,6 @@
module Gitlab
module PerformanceBar
- extend Gitlab::CurrentSettings
+ # extend Gitlab::CurrentSettings
ALLOWED_USER_IDS_KEY = 'performance_bar_allowed_user_ids:v2'.freeze
EXPIRY_TIME = 5.minutes
diff --git a/lib/gitlab/polling_interval.rb b/lib/gitlab/polling_interval.rb
index 4780675a492..45cba360279 100644
--- a/lib/gitlab/polling_interval.rb
+++ b/lib/gitlab/polling_interval.rb
@@ -1,6 +1,6 @@
module Gitlab
class PollingInterval
- extend Gitlab::CurrentSettings
+ # extend Gitlab::CurrentSettings
HEADER_NAME = 'Poll-Interval'.freeze
diff --git a/lib/gitlab/protocol_access.rb b/lib/gitlab/protocol_access.rb
index 09fa14764e6..465734990d3 100644
--- a/lib/gitlab/protocol_access.rb
+++ b/lib/gitlab/protocol_access.rb
@@ -1,6 +1,6 @@
module Gitlab
module ProtocolAccess
- extend Gitlab::CurrentSettings
+ # extend Gitlab::CurrentSettings
def self.allowed?(protocol)
if protocol == 'web'
diff --git a/lib/gitlab/recaptcha.rb b/lib/gitlab/recaptcha.rb
index c463dd487a0..201eafb0c1b 100644
--- a/lib/gitlab/recaptcha.rb
+++ b/lib/gitlab/recaptcha.rb
@@ -1,6 +1,6 @@
module Gitlab
module Recaptcha
- extend Gitlab::CurrentSettings
+ # extend Gitlab::CurrentSettings
def self.load_configurations!
if current_application_settings.recaptcha_enabled
diff --git a/lib/gitlab/sentry.rb b/lib/gitlab/sentry.rb
index 159d0e7952e..83a17e1a26c 100644
--- a/lib/gitlab/sentry.rb
+++ b/lib/gitlab/sentry.rb
@@ -1,6 +1,6 @@
module Gitlab
module Sentry
- extend Gitlab::CurrentSettings
+ # extend Gitlab::CurrentSettings
def self.enabled?
Rails.env.production? && current_application_settings.sentry_enabled?
diff --git a/lib/gitlab/sidekiq_throttler.rb b/lib/gitlab/sidekiq_throttler.rb
index 5512afa45a8..b2bee3b95c4 100644
--- a/lib/gitlab/sidekiq_throttler.rb
+++ b/lib/gitlab/sidekiq_throttler.rb
@@ -5,7 +5,7 @@ module Gitlab
if Gitlab::CurrentSettings.sidekiq_throttling_enabled?
require 'sidekiq-limit_fetch'
- Gitlab::CurrentSettings.current_application_settings.sidekiq_throttling_queues.each do |queue|
+ Gitlab::CurrentSettings.sidekiq_throttling_queues.each do |queue|
Sidekiq::Queue[queue].limit = queue_limit
end
end
@@ -16,7 +16,7 @@ module Gitlab
def queue_limit
@queue_limit ||=
begin
- factor = Gitlab::CurrentSettings.current_application_settings.sidekiq_throttling_factor
+ factor = Gitlab::CurrentSettings.sidekiq_throttling_factor
(factor * Sidekiq.options[:concurrency]).ceil
end
end
diff --git a/lib/gitlab/usage_data.rb b/lib/gitlab/usage_data.rb
index 70a403652e7..bfd2b614481 100644
--- a/lib/gitlab/usage_data.rb
+++ b/lib/gitlab/usage_data.rb
@@ -1,7 +1,7 @@
module Gitlab
class UsageData
class << self
- include Gitlab::CurrentSettings
+ # include Gitlab::CurrentSettings
def data(force_refresh: false)
Rails.cache.fetch('usage_data', force: force_refresh, expires_in: 2.weeks) { uncached_data }
diff --git a/lib/gitlab/visibility_level.rb b/lib/gitlab/visibility_level.rb
index c60bd91ea6e..6f752f4a01c 100644
--- a/lib/gitlab/visibility_level.rb
+++ b/lib/gitlab/visibility_level.rb
@@ -5,7 +5,7 @@
#
module Gitlab
module VisibilityLevel
- extend CurrentSettings
+ # extend CurrentSettings
extend ActiveSupport::Concern
included do
diff --git a/lib/tasks/import.rake b/lib/tasks/import.rake
index 7f86fd7b45e..146ce1da206 100644
--- a/lib/tasks/import.rake
+++ b/lib/tasks/import.rake
@@ -91,7 +91,7 @@ class GithubImport
end
def visibility_level
- @repo['private'] ? Gitlab::VisibilityLevel::PRIVATE : Gitlab::CurrentSettings.current_application_settings.default_project_visibility
+ @repo['private'] ? Gitlab::VisibilityLevel::PRIVATE : Gitlab::CurrentSettings.default_project_visibility
end
end