Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-01-27 03:07:50 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-27 03:07:50 +0300
commit431b84710e87a649de02d398568804f820e3b0fe (patch)
tree9cbc49a395615412c152d2bffa9255a3b37fafed /lib/gitlab/redis
parente04b8c1e60649802ae4249dae7fa7aaf3f0a83c7 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/redis')
-rw-r--r--lib/gitlab/redis/cluster_rate_limiting.rb11
-rw-r--r--lib/gitlab/redis/multi_store.rb22
-rw-r--r--lib/gitlab/redis/rate_limiting.rb23
3 files changed, 34 insertions, 22 deletions
diff --git a/lib/gitlab/redis/cluster_rate_limiting.rb b/lib/gitlab/redis/cluster_rate_limiting.rb
new file mode 100644
index 00000000000..e9d1e4f0c3f
--- /dev/null
+++ b/lib/gitlab/redis/cluster_rate_limiting.rb
@@ -0,0 +1,11 @@
+# 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 c0fab462786..46ffa8cbc1b 100644
--- a/lib/gitlab/redis/multi_store.rb
+++ b/lib/gitlab/redis/multi_store.rb
@@ -169,11 +169,15 @@ module Gitlab
end
def use_primary_and_secondary_stores?
- feature_enabled?("use_primary_and_secondary_stores_for")
+ Feature.feature_flags_available? &&
+ Feature.enabled?("use_primary_and_secondary_stores_for_#{instance_name.underscore}") && # rubocop:disable Cop/FeatureFlagUsage
+ !same_redis_store?
end
def use_primary_store_as_default?
- feature_enabled?("use_primary_store_as_default_for")
+ Feature.feature_flags_available? &&
+ Feature.enabled?("use_primary_store_as_default_for_#{instance_name.underscore}") && # rubocop:disable Cop/FeatureFlagUsage
+ !same_redis_store?
end
def increment_pipelined_command_error_count(command_name)
@@ -213,20 +217,6 @@ 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 4ae1d55e4ce..3a9fb63a495 100644
--- a/lib/gitlab/redis/rate_limiting.rb
+++ b/lib/gitlab/redis/rate_limiting.rb
@@ -3,13 +3,24 @@
module Gitlab
module Redis
class RateLimiting < ::Gitlab::Redis::Wrapper
- # The data we store on RateLimiting used to be stored on Cache.
- def self.config_fallback
- Cache
- end
+ 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)
- def self.cache_store
- @cache_store ||= ActiveSupport::Cache::RedisCacheStore.new(redis: pool, namespace: Cache::CACHE_NAMESPACE)
+ MultiStore.new(primary_store, secondary_store, name.demodulize)
+ end
end
end
end