Commit b816969d authored by Gabriel Mazetto's avatar Gabriel Mazetto

Added RequestStore caching to Gitlab::Geo

parent a87f7983
module Gitlab
module Geo
def self.current_node
GeoNode.find_by(host: Gitlab.config.gitlab.host,
port: Gitlab.config.gitlab.port,
relative_url_root: Gitlab.config.gitlab.relative_url_root)
RequestStore.store[:geo_node_current] ||= begin
GeoNode.find_by(host: Gitlab.config.gitlab.host,
port: Gitlab.config.gitlab.port,
relative_url_root: Gitlab.config.gitlab.relative_url_root)
end
end
def self.primary_node
GeoNode.find_by(primary: true)
RequestStore.store[:geo_node_primary] ||= GeoNode.find_by(primary: true)
end
def self.enabled?
GeoNode.exists?
RequestStore.store[:geo_node_enabled] ||= GeoNode.exists?
end
def self.readonly?
self.enabled? && !self.current_node.primary?
RequestStore.store[:geo_node_readonly] ||= self.enabled? && !self.current_node.primary?
end
def self.geo_node?(host:, port:)
......
RSpec.configure do |config|
config.before(:each) do
RequestStore.clear!
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment