diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-28 06:07:31 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-28 06:07:31 +0300 |
commit | b1c5e886f37f8123584a8d7a04d7cd32349b6094 (patch) | |
tree | 9a3f06f8500d13ac3b3f2f545d0c34cb2f5493f1 /lib/gitlab/redis | |
parent | 63895155f203b6af2df0689474059c1c7dfcfac8 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/redis')
-rw-r--r-- | lib/gitlab/redis/cluster_rate_limiting.rb | 11 | ||||
-rw-r--r-- | lib/gitlab/redis/multi_store.rb | 22 | ||||
-rw-r--r-- | lib/gitlab/redis/rate_limiting.rb | 23 |
3 files changed, 22 insertions, 34 deletions
diff --git a/lib/gitlab/redis/cluster_rate_limiting.rb b/lib/gitlab/redis/cluster_rate_limiting.rb deleted file mode 100644 index e9d1e4f0c3f..00000000000 --- a/lib/gitlab/redis/cluster_rate_limiting.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -module Gitlab - module Redis - class ClusterRateLimiting < ::Gitlab::Redis::Wrapper - def self.config_fallback - Cache - end - end - end -end diff --git a/lib/gitlab/redis/multi_store.rb b/lib/gitlab/redis/multi_store.rb index 46ffa8cbc1b..c0fab462786 100644 --- a/lib/gitlab/redis/multi_store.rb +++ b/lib/gitlab/redis/multi_store.rb @@ -169,15 +169,11 @@ module Gitlab end def use_primary_and_secondary_stores? - Feature.feature_flags_available? && - Feature.enabled?("use_primary_and_secondary_stores_for_#{instance_name.underscore}") && # rubocop:disable Cop/FeatureFlagUsage - !same_redis_store? + feature_enabled?("use_primary_and_secondary_stores_for") end def use_primary_store_as_default? - Feature.feature_flags_available? && - Feature.enabled?("use_primary_store_as_default_for_#{instance_name.underscore}") && # rubocop:disable Cop/FeatureFlagUsage - !same_redis_store? + feature_enabled?("use_primary_store_as_default_for") end def increment_pipelined_command_error_count(command_name) @@ -217,6 +213,20 @@ module Gitlab private + # @return [Boolean] + def feature_enabled?(prefix) + feature_table_exists? && + Feature.enabled?("#{prefix}_#{instance_name.underscore}") && # rubocop:disable Cop/FeatureFlagUsage + !same_redis_store? + end + + # @return [Boolean] + def feature_table_exists? + Feature::FlipperFeature.table_exists? + rescue StandardError + false + end + def default_store use_primary_store_as_default? ? primary_store : secondary_store end diff --git a/lib/gitlab/redis/rate_limiting.rb b/lib/gitlab/redis/rate_limiting.rb index 3a9fb63a495..4ae1d55e4ce 100644 --- a/lib/gitlab/redis/rate_limiting.rb +++ b/lib/gitlab/redis/rate_limiting.rb @@ -3,24 +3,13 @@ module Gitlab module Redis class RateLimiting < ::Gitlab::Redis::Wrapper - class << self - # The data we store on RateLimiting used to be stored on Cache. - def config_fallback - Cache - end - - def cache_store - @cache_store ||= ActiveSupport::Cache::RedisCacheStore.new(redis: pool, namespace: Cache::CACHE_NAMESPACE) - end - - private - - def redis - primary_store = ::Redis.new(::Gitlab::Redis::ClusterRateLimiting.params) - secondary_store = ::Redis.new(params) + # The data we store on RateLimiting used to be stored on Cache. + def self.config_fallback + Cache + end - MultiStore.new(primary_store, secondary_store, name.demodulize) - end + def self.cache_store + @cache_store ||= ActiveSupport::Cache::RedisCacheStore.new(redis: pool, namespace: Cache::CACHE_NAMESPACE) end end end |