Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
b816969d
Commit
b816969d
authored
Jan 22, 2016
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added RequestStore caching to Gitlab::Geo
parent
a87f7983
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
6 deletions
+13
-6
lib/gitlab/geo.rb
lib/gitlab/geo.rb
+8
-6
spec/support/request_store.rb
spec/support/request_store.rb
+5
-0
No files found.
lib/gitlab/geo.rb
View file @
b816969d
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
:)
...
...
spec/support/request_store.rb
0 → 100644
View file @
b816969d
RSpec
.
configure
do
|
config
|
config
.
before
(
:each
)
do
RequestStore
.
clear!
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment