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
47d4ede2
Commit
47d4ede2
authored
Mar 15, 2016
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
/refresh_wikis endpoint and workers to handle sync on secondaries
parent
ffcab7e1
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
4 deletions
+56
-4
app/models/project_wiki.rb
app/models/project_wiki.rb
+4
-0
app/services/geo/schedule_wiki_repo_update_service.rb
app/services/geo/schedule_wiki_repo_update_service.rb
+15
-0
app/workers/geo_repository_update_worker.rb
app/workers/geo_repository_update_worker.rb
+4
-4
app/workers/geo_wiki_repository_update_worker.rb
app/workers/geo_wiki_repository_update_worker.rb
+23
-0
lib/api/geo.rb
lib/api/geo.rb
+10
-0
No files found.
app/models/project_wiki.rb
View file @
47d4ede2
...
@@ -54,6 +54,10 @@ class ProjectWiki
...
@@ -54,6 +54,10 @@ class ProjectWiki
end
end
end
end
def
repository_exists?
!!
repository
.
exists?
end
def
empty?
def
empty?
pages
.
empty?
pages
.
empty?
end
end
...
...
app/services/geo/schedule_wiki_repo_update_service.rb
0 → 100644
View file @
47d4ede2
module
Geo
class
ScheduleWikiRepoUpdateService
attr_reader
:projects
def
initialize
(
projects
)
@projects
=
projects
end
def
execute
@projects
.
each
do
|
project
|
GeoWikiRepositoryUpdateWorker
.
perform_async
(
project
[
'id'
],
project
[
'clone_url'
])
end
end
end
end
app/workers/geo_repository_update_worker.rb
View file @
47d4ede2
...
@@ -9,13 +9,13 @@ class GeoRepositoryUpdateWorker
...
@@ -9,13 +9,13 @@ class GeoRepositoryUpdateWorker
def
perform
(
project_id
,
clone_url
)
def
perform
(
project_id
,
clone_url
)
@project
=
Project
.
find
(
project_id
)
@project
=
Project
.
find
(
project_id
)
fetch_repository
(
@project
,
clone_url
)
fetch_repository
(
clone_url
)
end
end
private
private
def
fetch_repository
(
project
,
remote_url
)
def
fetch_repository
(
remote_url
)
project
.
create_repository
unless
project
.
repository_exists?
@project
.
create_repository
unless
@
project
.
repository_exists?
project
.
repository
.
fetch_geo_mirror
(
remote_url
)
@
project
.
repository
.
fetch_geo_mirror
(
remote_url
)
end
end
end
end
app/workers/geo_wiki_repository_update_worker.rb
0 → 100644
View file @
47d4ede2
class
GeoWikiRepositoryUpdateWorker
include
Sidekiq
::
Worker
include
Gitlab
::
ShellAdapter
sidekiq_options
queue: :default
attr_accessor
:project
def
perform
(
project_id
,
clone_url
)
@project
=
Project
.
find
(
project_id
)
fetch_repository
(
clone_url
)
end
private
def
fetch_repository
(
remote_url
)
# Second .wiki call returns a Gollum::Wiki, and it will always create the physical repository when not found
if
@project
.
wiki
.
wiki
.
exist?
@project
.
wiki
.
repository
.
fetch_geo_mirror
(
remote_url
)
end
end
end
lib/api/geo.rb
View file @
47d4ede2
...
@@ -13,6 +13,16 @@ module API
...
@@ -13,6 +13,16 @@ module API
required_attributes!
[
:projects
]
required_attributes!
[
:projects
]
::
Geo
::
ScheduleRepoUpdateService
.
new
(
params
[
:projects
]).
execute
::
Geo
::
ScheduleRepoUpdateService
.
new
(
params
[
:projects
]).
execute
end
end
# Enqueue a batch of IDs of wiki's projects to have their
# wiki repositories updated
#
# Example request:
# POST /refresh_wikis
post
'refresh_wikis'
do
required_attributes!
[
:projects
]
::
Geo
::
ScheduleWikiRepoUpdateService
.
new
(
params
[
:projects
]).
execute
end
end
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