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
357090bb
Commit
357090bb
authored
Mar 03, 2016
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
we should reuse same redis connection for UpdateQueue
parent
413cb0af
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
14 deletions
+18
-14
lib/gitlab/geo/update_queue.rb
lib/gitlab/geo/update_queue.rb
+18
-14
No files found.
lib/gitlab/geo/update_queue.rb
View file @
357090bb
...
...
@@ -5,12 +5,8 @@ module Gitlab
NAMESPACE
=
'geo:gitlab'
QUEUE
=
'updated_projects'
def
initialize
@redis
=
redis_connection
end
def
store
(
data
)
@
redis
.
rpush
(
QUEUE
,
data
.
to_json
)
redis
.
rpush
(
QUEUE
,
data
.
to_json
)
expire_queue_size!
end
...
...
@@ -28,9 +24,9 @@ module Gitlab
projects
=
[]
bsize
=
batch_size
@
redis
.
multi
do
projects
=
@
redis
.
lrange
(
QUEUE
,
0
,
bsize
-
1
)
@
redis
.
ltrim
(
QUEUE
,
bsize
,
-
1
)
redis
.
multi
do
projects
=
redis
.
lrange
(
QUEUE
,
0
,
bsize
-
1
)
redis
.
ltrim
(
QUEUE
,
bsize
,
-
1
)
end
expire_queue_size!
...
...
@@ -38,10 +34,10 @@ module Gitlab
end
def
store_batched_data
(
projects
)
@
redis
.
pipelined
do
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!
...
...
@@ -60,17 +56,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!
...
...
@@ -82,7 +78,11 @@ module Gitlab
data
end
def
redis_connection
def
redis
self
.
class
.
redis
end
def
self
.
redis_connection
redis_config_file
=
Rails
.
root
.
join
(
'config'
,
'resque.yml'
)
redis_url_string
=
if
File
.
exists?
(
redis_config_file
)
...
...
@@ -93,6 +93,10 @@ module Gitlab
Redis
::
Namespace
.
new
(
NAMESPACE
,
redis:
Redis
.
new
(
url:
redis_url_string
))
end
def
self
.
redis
@redis
||=
redis_connection
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