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
5db0f3f3
Commit
5db0f3f3
authored
Nov 16, 2016
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Isolate ProjectCacheWorker specific Geo code in prepended module
parent
4fffe6b7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
17 deletions
+33
-17
app/workers/project_cache_worker.rb
app/workers/project_cache_worker.rb
+2
-17
lib/ee/workers/project_cache_worker.rb
lib/ee/workers/project_cache_worker.rb
+31
-0
No files found.
app/workers/project_cache_worker.rb
View file @
5db0f3f3
...
...
@@ -6,6 +6,7 @@
class
ProjectCacheWorker
include
Sidekiq
::
Worker
include
DedicatedSidekiqQueue
prepend
EE
::
Workers
::
ProjectCacheWorker
LEASE_TIMEOUT
=
15
.
minutes
.
to_i
...
...
@@ -32,11 +33,7 @@ class ProjectCacheWorker
return
end
if
Gitlab
::
Geo
.
secondary?
update_geo_caches
(
project_id
)
else
update_caches
(
project_id
)
end
update_caches
(
project_id
)
end
def
update_caches
(
project_id
)
...
...
@@ -52,18 +49,6 @@ class ProjectCacheWorker
end
end
# Geo should only update Redis based cache, as data store in the database
# will be updated on primary and replicated to the secondaries.
def
update_geo_caches
(
project_id
)
project
=
Project
.
find
(
project_id
)
return
unless
project
.
repository
.
exists?
if
project
.
repository
.
root_ref
project
.
repository
.
build_cache
end
end
def
try_obtain_lease_for
(
project_id
)
self
.
class
.
lease_for
(
project_id
).
try_obtain
end
...
...
lib/ee/workers/project_cache_worker.rb
0 → 100644
View file @
5db0f3f3
module
EE
module
Workers
# Geo specific code for cache re-generation
#
# This module is intended to encapsulate EE-specific methods
# and be **prepended** in the `ProjectCacheWorker` class.
module
ProjectCacheWorker
def
update_caches
(
project_id
)
if
::
Gitlab
::
Geo
.
secondary?
update_geo_caches
(
project_id
)
else
super
end
end
private
# Geo should only update Redis based cache, as data store in the database
# will be updated on primary and replicated to the secondaries.
def
update_geo_caches
(
project_id
)
project
=
Project
.
find
(
project_id
)
return
unless
project
.
repository
.
exists?
if
project
.
repository
.
root_ref
project
.
repository
.
build_cache
end
end
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