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
e35b85ae
Commit
e35b85ae
authored
Feb 07, 2017
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor `cache_boolean` to `cache_value` for all Geo calls
parent
6ec3953e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
12 deletions
+10
-12
lib/gitlab/geo.rb
lib/gitlab/geo.rb
+10
-12
No files found.
lib/gitlab/geo.rb
View file @
e35b85ae
...
...
@@ -3,7 +3,7 @@ module Gitlab
class
OauthApplicationUndefinedError
<
StandardError
;
end
def
self
.
current_node
RequestStore
.
store
[
:geo_node_current
]
||=
begin
self
.
cache_value
(
:geo_node_current
)
do
GeoNode
.
find_by
(
host:
Gitlab
.
config
.
gitlab
.
host
,
port:
Gitlab
.
config
.
gitlab
.
port
,
relative_url_root:
Gitlab
.
config
.
gitlab
.
relative_url_root
)
...
...
@@ -11,15 +11,15 @@ module Gitlab
end
def
self
.
primary_node
RequestStore
.
store
[
:geo_primary_node
]
||=
GeoNode
.
find_by
(
primary:
true
)
self
.
cache_value
(
:geo_primary_node
)
{
GeoNode
.
find_by
(
primary:
true
)
}
end
def
self
.
secondary_nodes
RequestStore
.
store
[
:geo_secondary_nodes
]
||=
GeoNode
.
where
(
primary:
false
)
self
.
cache_value
(
:geo_secondary_nodes
)
{
GeoNode
.
where
(
primary:
false
)
}
end
def
self
.
enabled?
self
.
cache_
boolean
(
:geo_node_enabled
)
{
GeoNode
.
exists?
}
self
.
cache_
value
(
:geo_node_enabled
)
{
GeoNode
.
exists?
}
end
def
self
.
license_allows?
...
...
@@ -27,11 +27,11 @@ module Gitlab
end
def
self
.
primary?
self
.
cache_
boolean
(
:geo_node_primary
)
{
self
.
enabled?
&&
self
.
current_node
&&
self
.
current_node
.
primary?
}
self
.
cache_
value
(
:geo_node_primary
)
{
self
.
enabled?
&&
self
.
current_node
&&
self
.
current_node
.
primary?
}
end
def
self
.
secondary?
self
.
cache_
boolean
(
:geo_node_secondary
)
{
self
.
enabled?
&&
self
.
current_node
&&
!
self
.
current_node
.
primary?
}
self
.
cache_
value
(
:geo_node_secondary
)
{
self
.
enabled?
&&
self
.
current_node
&&
!
self
.
current_node
.
primary?
}
end
def
self
.
geo_node?
(
host
:,
port
:)
...
...
@@ -49,17 +49,15 @@ module Gitlab
def
self
.
oauth_authentication
return
false
unless
Gitlab
::
Geo
.
secondary?
RequestStore
.
store
[
:geo_oauth_application
]
||=
self
.
cache_value
(
:geo_oauth_application
)
do
Gitlab
::
Geo
.
current_node
.
oauth_application
or
raise
OauthApplicationUndefinedError
end
end
def
self
.
cache_
boolean
(
key
,
&
block
)
def
self
.
cache_
value
(
key
,
&
block
)
return
yield
unless
RequestStore
.
active?
val
=
RequestStore
.
store
[
key
]
return
val
unless
val
.
nil?
RequestStore
[
key
]
=
yield
RequestStore
.
fetch
(
key
)
{
yield
}
end
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