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
d045cbef
Commit
d045cbef
authored
Jul 24, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move RepositorySyncWorker under the Geo namespace
parent
f01bbcb2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
40 deletions
+42
-40
app/workers/geo/repository_sync_worker.rb
app/workers/geo/repository_sync_worker.rb
+39
-0
app/workers/geo_repository_sync_worker.rb
app/workers/geo_repository_sync_worker.rb
+0
-37
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+1
-1
lib/gitlab/geo.rb
lib/gitlab/geo.rb
+1
-1
spec/workers/geo/repository_sync_worker_spec.rb
spec/workers/geo/repository_sync_worker_spec.rb
+1
-1
No files found.
app/workers/geo/repository_sync_worker.rb
0 → 100644
View file @
d045cbef
module
Geo
class
RepositorySyncWorker
<
Geo
::
BaseSchedulerWorker
BACKOFF_DELAY
=
5
.
minutes
MAX_CAPACITY
=
25
private
def
max_capacity
MAX_CAPACITY
end
def
schedule_job
(
project_id
)
job_id
=
Geo
::
ProjectSyncWorker
.
perform_in
(
BACKOFF_DELAY
,
project_id
,
Time
.
now
)
{
id:
project_id
,
job_id:
job_id
}
if
job_id
end
def
load_pending_resources
project_ids_not_synced
=
find_project_ids_not_synced
project_ids_updated_recently
=
find_project_ids_updated_recently
interleave
(
project_ids_not_synced
,
project_ids_updated_recently
)
end
def
find_project_ids_not_synced
Project
.
where
.
not
(
id:
Geo
::
ProjectRegistry
.
synced
.
pluck
(
:project_id
))
.
order
(
last_repository_updated_at: :desc
)
.
limit
(
db_retrieve_batch_size
)
.
pluck
(
:id
)
end
def
find_project_ids_updated_recently
Geo
::
ProjectRegistry
.
dirty
.
order
(
Gitlab
::
Database
.
nulls_first_order
(
:last_repository_synced_at
,
:desc
))
.
limit
(
db_retrieve_batch_size
)
.
pluck
(
:project_id
)
end
end
end
app/workers/geo_repository_sync_worker.rb
deleted
100644 → 0
View file @
f01bbcb2
class
GeoRepositorySyncWorker
<
Geo
::
BaseSchedulerWorker
BACKOFF_DELAY
=
5
.
minutes
MAX_CAPACITY
=
25
private
def
max_capacity
MAX_CAPACITY
end
def
schedule_job
(
project_id
)
job_id
=
Geo
::
ProjectSyncWorker
.
perform_in
(
BACKOFF_DELAY
,
project_id
,
Time
.
now
)
{
id:
project_id
,
job_id:
job_id
}
if
job_id
end
def
load_pending_resources
project_ids_not_synced
=
find_project_ids_not_synced
project_ids_updated_recently
=
find_project_ids_updated_recently
interleave
(
project_ids_not_synced
,
project_ids_updated_recently
)
end
def
find_project_ids_not_synced
Project
.
where
.
not
(
id:
Geo
::
ProjectRegistry
.
synced
.
pluck
(
:project_id
))
.
order
(
last_repository_updated_at: :desc
)
.
limit
(
db_retrieve_batch_size
)
.
pluck
(
:id
)
end
def
find_project_ids_updated_recently
Geo
::
ProjectRegistry
.
dirty
.
order
(
Gitlab
::
Database
.
nulls_first_order
(
:last_repository_synced_at
,
:desc
))
.
limit
(
db_retrieve_batch_size
)
.
pluck
(
:project_id
)
end
end
config/initializers/1_settings.rb
View file @
d045cbef
...
...
@@ -409,7 +409,7 @@ Settings.cron_jobs['geo_bulk_notify_worker']['cron'] ||= '*/10 * * * * *'
Settings
.
cron_jobs
[
'geo_bulk_notify_worker'
][
'job_class'
]
||=
'GeoBulkNotifyWorker'
Settings
.
cron_jobs
[
'geo_repository_sync_worker'
]
||=
Settingslogic
.
new
({})
Settings
.
cron_jobs
[
'geo_repository_sync_worker'
][
'cron'
]
||=
'*/5 * * * *'
Settings
.
cron_jobs
[
'geo_repository_sync_worker'
][
'job_class'
]
||=
'GeoRepositorySyncWorker'
Settings
.
cron_jobs
[
'geo_repository_sync_worker'
][
'job_class'
]
||=
'Geo
::
RepositorySyncWorker'
Settings
.
cron_jobs
[
'geo_file_download_dispatch_worker'
]
||=
Settingslogic
.
new
({})
Settings
.
cron_jobs
[
'geo_file_download_dispatch_worker'
][
'cron'
]
||=
'5 * * * *'
Settings
.
cron_jobs
[
'geo_file_download_dispatch_worker'
][
'job_class'
]
||=
'Geo::FileDownloadDispatchWorker'
...
...
lib/gitlab/geo.rb
View file @
d045cbef
...
...
@@ -41,7 +41,7 @@ module Gitlab
def
self
.
current_node_enabled?
# No caching of the enabled! If we cache it and an admin disables
# this node, an active GeoRepositorySyncWorker would keep going for up
# this node, an active Geo
::
RepositorySyncWorker would keep going for up
# to max run time after the node was disabled.
Gitlab
::
Geo
.
current_node
.
reload
.
enabled?
end
...
...
spec/workers/geo
_
repository_sync_worker_spec.rb
→
spec/workers/geo
/
repository_sync_worker_spec.rb
View file @
d045cbef
require
'spec_helper'
describe
GeoRepositorySyncWorker
do
describe
Geo
::
RepositorySyncWorker
do
let!
(
:primary
)
{
create
(
:geo_node
,
:primary
,
host:
'primary-geo-node'
)
}
let!
(
:secondary
)
{
create
(
:geo_node
,
:current
)
}
let!
(
:project_1
)
{
create
(
:empty_project
)
}
...
...
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