Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
1e1c89c2
提交
1e1c89c2
authored
2月 04, 2016
作者:
Jeromy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
command to clear inactive requests from request log
License: MIT Signed-off-by:
Jeromy
<
jeromyj@gmail.com
>
上级
e8c753d2
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
26 行增加
和
1 行删除
+26
-1
reqlog.go
commands/reqlog.go
+14
-1
active.go
core/commands/active.go
+12
-0
没有找到文件。
commands/reqlog.go
浏览文件 @
1e1c89c2
...
@@ -66,6 +66,19 @@ func (rl *ReqLog) Add(req Request) *ReqLogEntry {
...
@@ -66,6 +66,19 @@ func (rl *ReqLog) Add(req Request) *ReqLogEntry {
return
rle
return
rle
}
}
func
(
rl
*
ReqLog
)
ClearInactive
()
{
rl
.
lock
.
Lock
()
defer
rl
.
lock
.
Unlock
()
i
:=
0
for
j
:=
0
;
j
<
len
(
rl
.
Requests
);
j
++
{
if
rl
.
Requests
[
j
]
.
Active
{
rl
.
Requests
[
i
]
=
rl
.
Requests
[
j
]
i
++
}
}
rl
.
Requests
=
rl
.
Requests
[
:
i
]
}
func
(
rl
*
ReqLog
)
maybeCleanup
()
{
func
(
rl
*
ReqLog
)
maybeCleanup
()
{
// only do it every so often or it might
// only do it every so often or it might
// become a perf issue
// become a perf issue
...
@@ -79,7 +92,7 @@ func (rl *ReqLog) cleanup() {
...
@@ -79,7 +92,7 @@ func (rl *ReqLog) cleanup() {
// drop all logs at are inactive and more than an hour old
// drop all logs at are inactive and more than an hour old
for
;
i
<
len
(
rl
.
Requests
);
i
++
{
for
;
i
<
len
(
rl
.
Requests
);
i
++
{
req
:=
rl
.
Requests
[
i
]
req
:=
rl
.
Requests
[
i
]
if
req
.
Active
||
req
.
EndTime
.
Add
(
time
.
Hour
)
.
After
(
time
.
Now
())
{
if
req
.
Active
||
req
.
EndTime
.
Add
(
time
.
Hour
/
2
)
.
After
(
time
.
Now
())
{
break
break
}
}
}
}
...
...
core/commands/active.go
浏览文件 @
1e1c89c2
...
@@ -24,6 +24,9 @@ Lists running and recently run commands.
...
@@ -24,6 +24,9 @@ Lists running and recently run commands.
Options
:
[]
cmds
.
Option
{
Options
:
[]
cmds
.
Option
{
cmds
.
BoolOption
(
"v"
,
"verbose"
,
"print more verbose output"
),
cmds
.
BoolOption
(
"v"
,
"verbose"
,
"print more verbose output"
),
},
},
Subcommands
:
map
[
string
]
*
cmds
.
Command
{
"clear"
:
clearInactiveCmd
,
},
Marshalers
:
map
[
cmds
.
EncodingType
]
cmds
.
Marshaler
{
Marshalers
:
map
[
cmds
.
EncodingType
]
cmds
.
Marshaler
{
cmds
.
Text
:
func
(
res
cmds
.
Response
)
(
io
.
Reader
,
error
)
{
cmds
.
Text
:
func
(
res
cmds
.
Response
)
(
io
.
Reader
,
error
)
{
out
,
ok
:=
res
.
Output
()
.
(
*
[]
*
cmds
.
ReqLogEntry
)
out
,
ok
:=
res
.
Output
()
.
(
*
[]
*
cmds
.
ReqLogEntry
)
...
@@ -80,3 +83,12 @@ Lists running and recently run commands.
...
@@ -80,3 +83,12 @@ Lists running and recently run commands.
},
},
Type
:
[]
*
cmds
.
ReqLogEntry
{},
Type
:
[]
*
cmds
.
ReqLogEntry
{},
}
}
var
clearInactiveCmd
=
&
cmds
.
Command
{
Helptext
:
cmds
.
HelpText
{
Tagline
:
"Clear inactive requests from the log"
,
},
Run
:
func
(
req
cmds
.
Request
,
res
cmds
.
Response
)
{
req
.
InvocContext
()
.
ReqLog
.
ClearInactive
()
},
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论