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
61fb7906
Commit
61fb7906
authored
Mar 14, 2016
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored UpdateQueue to be more generic.
Renamed EnqueueUpdateService to be specific for Project Updates
parent
545b6b1d
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
24 additions
and
24 deletions
+24
-24
app/services/geo/base_service.rb
app/services/geo/base_service.rb
+0
-7
app/services/geo/enqueue_project_update_service.rb
app/services/geo/enqueue_project_update_service.rb
+2
-2
app/services/geo/notify_nodes_service.rb
app/services/geo/notify_nodes_service.rb
+5
-1
lib/gitlab/geo.rb
lib/gitlab/geo.rb
+1
-1
lib/gitlab/geo/update_queue.rb
lib/gitlab/geo/update_queue.rb
+11
-8
spec/lib/gitlab/geo/update_queue_spec.rb
spec/lib/gitlab/geo/update_queue_spec.rb
+1
-1
spec/lib/gitlab/geo_spec.rb
spec/lib/gitlab/geo_spec.rb
+2
-2
spec/services/geo/enqueue_update_service_spec.rb
spec/services/geo/enqueue_update_service_spec.rb
+2
-2
No files found.
app/services/geo/base_service.rb
deleted
100644 → 0
View file @
545b6b1d
module
Geo
class
BaseService
def
initialize
@queue
=
Gitlab
::
Geo
::
UpdateQueue
.
new
end
end
end
app/services/geo/enqueue_update_service.rb
→
app/services/geo/enqueue_
project_
update_service.rb
View file @
61fb7906
module
Geo
class
Enqueue
UpdateService
<
Geo
::
Bas
eService
class
Enqueue
ProjectUpdat
eService
attr_reader
:project
def
initialize
(
project
)
super
(
)
@queue
=
Gitlab
::
Geo
::
UpdateQueue
.
new
(
'updated_projects'
)
@project
=
project
end
...
...
app/services/geo/notify_nodes_service.rb
View file @
61fb7906
module
Geo
class
NotifyNodesService
<
Geo
::
BaseService
class
NotifyNodesService
include
HTTParty
# HTTParty timeout
default_timeout
Gitlab
.
config
.
gitlab
.
webhook_timeout
def
initialize
@queue
=
Gitlab
::
Geo
::
UpdateQueue
.
new
(
'updated_projects'
)
end
def
execute
return
if
@queue
.
empty?
projects
=
@queue
.
fetch_batched_data
...
...
lib/gitlab/geo.rb
View file @
61fb7906
...
...
@@ -35,7 +35,7 @@ module Gitlab
end
def
self
.
notify_update
(
project
)
::
Geo
::
EnqueueUpdateService
.
new
(
project
).
execute
::
Geo
::
Enqueue
Project
UpdateService
.
new
(
project
).
execute
end
def
self
.
bulk_notify_job
...
...
lib/gitlab/geo/update_queue.rb
View file @
61fb7906
...
...
@@ -3,10 +3,13 @@ module Gitlab
class
UpdateQueue
BATCH_SIZE
=
250
NAMESPACE
=
'geo:gitlab'
QUEUE
=
'updated_projects'
def
initialize
(
queue
)
@queue
=
queue
end
def
store
(
data
)
redis
.
rpush
(
QUEUE
,
data
.
to_json
)
redis
.
rpush
(
@queue
,
data
.
to_json
)
expire_queue_size!
end
...
...
@@ -25,8 +28,8 @@ module Gitlab
bsize
=
batch_size
redis
.
multi
do
projects
=
redis
.
lrange
(
QUEUE
,
0
,
bsize
-
1
)
redis
.
ltrim
(
QUEUE
,
bsize
,
-
1
)
projects
=
redis
.
lrange
(
@queue
,
0
,
bsize
-
1
)
redis
.
ltrim
(
@queue
,
bsize
,
-
1
)
end
expire_queue_size!
...
...
@@ -37,7 +40,7 @@ module Gitlab
redis
.
pipelined
do
projects
.
reverse_each
do
|
project
|
# enqueue again to the head of the queue
redis
.
lpush
(
QUEUE
,
project
.
to_json
)
redis
.
lpush
(
@queue
,
project
.
to_json
)
end
end
expire_queue_size!
...
...
@@ -56,17 +59,17 @@ module Gitlab
end
def
empty!
redis
.
del
(
QUEUE
)
redis
.
del
(
@queue
)
end
protected
def
fetch
(
start
,
stop
)
deserialize
(
redis
.
lrange
(
QUEUE
,
start
,
stop
))
deserialize
(
redis
.
lrange
(
@queue
,
start
,
stop
))
end
def
fetch_queue_size
redis
.
llen
(
QUEUE
)
redis
.
llen
(
@queue
)
end
def
expire_queue_size!
...
...
spec/lib/gitlab/geo/update_queue_spec.rb
View file @
61fb7906
require
'spec_helper'
describe
Gitlab
::
Geo
::
UpdateQueue
do
subject
{
described_class
.
new
}
subject
{
described_class
.
new
(
'test_queue'
)
}
let
(
:dummy_data
)
{
{
'id'
=>
1
,
'clone_url'
=>
'git@localhost:repo/path.git'
}
}
let
(
:dummy_data2
)
{
{
'id'
=>
99
,
'clone_url'
=>
'git@localhost:other_repo/path.git'
}
}
let
(
:multiple_dummy_data
)
{
[
dummy_data
,
dummy_data2
]
*
10
}
...
...
spec/lib/gitlab/geo_spec.rb
View file @
61fb7906
...
...
@@ -73,8 +73,8 @@ describe Gitlab::Geo, lib: true do
let
(
:project
)
{
FactoryGirl
.
build
(
:project
)
}
it
'delegates to NotifyService'
do
expect
(
Geo
::
EnqueueUpdateService
).
to
receive
(
:new
).
with
(
project
).
and_call_original
expect_any_instance_of
(
Geo
::
EnqueueUpdateService
).
to
receive
(
:execute
)
expect
(
Geo
::
Enqueue
Project
UpdateService
).
to
receive
(
:new
).
with
(
project
).
and_call_original
expect_any_instance_of
(
Geo
::
Enqueue
Project
UpdateService
).
to
receive
(
:execute
)
described_class
.
notify_update
(
project
)
end
...
...
spec/services/geo/enqueue_update_service_spec.rb
View file @
61fb7906
describe
Geo
::
EnqueueUpdateService
,
service:
true
do
subject
{
Geo
::
EnqueueUpdateService
.
new
(
project
)
}
describe
Geo
::
Enqueue
Project
UpdateService
,
service:
true
do
subject
{
Geo
::
Enqueue
Project
UpdateService
.
new
(
project
)
}
let
(
:project
)
{
double
(
:project
)
}
let
(
:fake_url
)
{
'git@localhost:repo/path.git'
}
let
(
:fake_id
)
{
999
}
...
...
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