Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
640a4c88
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
640a4c88
编写于
10月 03, 2016
作者:
P
Paco Guzman
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use higher size on Gitlab::Redis connection pool on Sidekiq servers
上级
0bbeff3d
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
46 addition
and
1 deletion
+46
-1
CHANGELOG
CHANGELOG
+1
-0
lib/gitlab/redis.rb
lib/gitlab/redis.rb
+11
-1
spec/lib/gitlab/redis_spec.rb
spec/lib/gitlab/redis_spec.rb
+34
-0
未找到文件。
CHANGELOG
浏览文件 @
640a4c88
...
...
@@ -37,6 +37,7 @@ v 8.13.0 (unreleased)
- Append issue template to existing description !6149 (Joseph Frazier)
- Trending projects now only show public projects and the list of projects is cached for a day
- Revoke button in Applications Settings underlines on hover.
- Use higher size on Gitlab::Redis connection pool on Sidekiq servers
- Add missing values to linter !6276 (Katarzyna Kobierska Ula Budziszewska)
- Fix Long commit messages overflow viewport in file tree
- Revert avoid touching file system on Build#artifacts?
...
...
lib/gitlab/redis.rb
浏览文件 @
640a4c88
...
...
@@ -24,10 +24,20 @@ module Gitlab
end
def
with
@pool
||=
ConnectionPool
.
new
{
::
Redis
.
new
(
params
)
}
@pool
||=
ConnectionPool
.
new
(
size:
pool_size
)
{
::
Redis
.
new
(
params
)
}
@pool
.
with
{
|
redis
|
yield
redis
}
end
def
pool_size
if
Sidekiq
.
server?
# the pool will be used in a multi-threaded context
Sidekiq
.
options
[
:concurrency
]
+
5
else
# probably this is a Unicorn process, so single threaded
5
end
end
def
_raw_config
return
@_raw_config
if
defined?
(
@_raw_config
)
...
...
spec/lib/gitlab/redis_spec.rb
浏览文件 @
640a4c88
...
...
@@ -88,6 +88,34 @@ describe Gitlab::Redis do
end
end
describe
'.with'
do
before
{
clear_pool
}
after
{
clear_pool
}
context
'when running not on sidekiq workers'
do
before
{
allow
(
Sidekiq
).
to
receive
(
:server?
).
and_return
(
false
)
}
it
'instantiates a connection pool with size 5'
do
expect
(
ConnectionPool
).
to
receive
(
:new
).
with
(
size:
5
).
and_call_original
described_class
.
with
{
|
_redis
|
true
}
end
end
context
'when running on sidekiq workers'
do
before
do
allow
(
Sidekiq
).
to
receive
(
:server?
).
and_return
(
true
)
allow
(
Sidekiq
).
to
receive
(
:options
).
and_return
({
concurrency:
18
})
end
it
'instantiates a connection pool with a size based on the concurrency of the worker'
do
expect
(
ConnectionPool
).
to
receive
(
:new
).
with
(
size:
18
+
5
).
and_call_original
described_class
.
with
{
|
_redis
|
true
}
end
end
end
describe
'#raw_config_hash'
do
it
'returns default redis url when no config file is present'
do
expect
(
subject
).
to
receive
(
:fetch_config
)
{
false
}
...
...
@@ -114,4 +142,10 @@ describe Gitlab::Redis do
rescue
NameError
# raised if @_raw_config was not set; ignore
end
def
clear_pool
described_class
.
remove_instance_variable
(
:@pool
)
rescue
NameError
# raised if @pool was not set; ignore
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录