Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
454cd454
提交
454cd454
authored
2月 02, 2015
作者:
Brian Tiger Chow
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(fsrepo) add eventlog config to repo/config struct
上级
d0583768
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
31 行增加
和
14 行删除
+31
-14
config.go
repo/config/config.go
+1
-0
log.go
repo/config/log.go
+8
-0
component.go
repo/fsrepo/component/component.go
+1
-1
config.go
repo/fsrepo/component/config.go
+4
-2
datastore.go
repo/fsrepo/component/datastore.go
+1
-1
datastore_test.go
repo/fsrepo/component/datastore_test.go
+2
-2
eventlog.go
repo/fsrepo/component/eventlog.go
+9
-4
fsrepo.go
repo/fsrepo/fsrepo.go
+5
-4
没有找到文件。
repo/config/config.go
浏览文件 @
454cd454
...
...
@@ -24,6 +24,7 @@ type Config struct {
Bootstrap
[]
string
// local nodes's bootstrap peer addresses
Tour
Tour
// local node's tour position
Gateway
Gateway
// local node's gateway server options
Log
Log
}
const
(
...
...
repo/config/log.go
0 → 100644
浏览文件 @
454cd454
package
config
type
Log
struct
{
MaxSizeMB
uint64
MaxBackups
uint64
MaxAgeDays
uint64
}
repo/fsrepo/component/component.go
浏览文件 @
454cd454
...
...
@@ -7,7 +7,7 @@ import (
)
type
Component
interface
{
Open
()
error
Open
(
*
config
.
Config
)
error
io
.
Closer
SetPath
(
string
)
}
...
...
repo/fsrepo/component/config.go
浏览文件 @
454cd454
...
...
@@ -37,8 +37,10 @@ func InitConfigComponent(path string, conf *config.Config) error {
return
nil
}
// Open returns an error if the config file is not present.
func
(
c
*
ConfigComponent
)
Open
()
error
{
// Open returns an error if the config file is not present. This component is
// always called with a nil config parameter. Other components rely on the
// config, to keep the interface uniform, it is special-cased.
func
(
c
*
ConfigComponent
)
Open
(
_
*
config
.
Config
)
error
{
configFilename
,
err
:=
config
.
Filename
(
c
.
path
)
if
err
!=
nil
{
return
err
...
...
repo/fsrepo/component/datastore.go
浏览文件 @
454cd454
...
...
@@ -66,7 +66,7 @@ func (dsc *DatastoreComponent) SetPath(p string) {
func
(
dsc
*
DatastoreComponent
)
Datastore
()
datastore
.
ThreadSafeDatastore
{
return
dsc
.
ds
}
// Open returns an error if the config file is not present.
func
(
dsc
*
DatastoreComponent
)
Open
()
error
{
func
(
dsc
*
DatastoreComponent
)
Open
(
*
config
.
Config
)
error
{
dsLock
.
Lock
()
defer
dsLock
.
Unlock
()
...
...
repo/fsrepo/component/datastore_test.go
浏览文件 @
454cd454
...
...
@@ -22,8 +22,8 @@ func TestOpenMoreThanOnceInSameProcess(t *testing.T) {
path
:=
testRepoPath
(
t
)
dsc1
:=
DatastoreComponent
{
path
:
path
}
dsc2
:=
DatastoreComponent
{
path
:
path
}
assert
.
Nil
(
dsc1
.
Open
(),
t
,
"first repo should open successfully"
)
assert
.
Nil
(
dsc2
.
Open
(),
t
,
"second repo should open successfully"
)
assert
.
Nil
(
dsc1
.
Open
(
nil
),
t
,
"first repo should open successfully"
)
assert
.
Nil
(
dsc2
.
Open
(
nil
),
t
,
"second repo should open successfully"
)
assert
.
Nil
(
dsc1
.
Close
(),
t
)
assert
.
Nil
(
dsc2
.
Close
(),
t
)
...
...
repo/fsrepo/component/eventlog.go
浏览文件 @
454cd454
...
...
@@ -35,17 +35,22 @@ func (c *EventlogComponent) Close() error {
return
nil
}
func
(
c
*
EventlogComponent
)
Open
()
error
{
func
(
c
*
EventlogComponent
)
Open
(
config
*
config
.
Config
)
error
{
// log.Debugf("writing eventlogs to ...", c.path)
return
configureEventLoggerAtRepoPath
(
c
.
path
)
return
configureEventLoggerAtRepoPath
(
c
onfig
,
c
.
path
)
}
func
configureEventLoggerAtRepoPath
(
repoPath
string
)
error
{
func
configureEventLoggerAtRepoPath
(
c
*
config
.
Config
,
repoPath
string
)
error
{
eventlog
.
Configure
(
eventlog
.
LevelInfo
)
eventlog
.
Configure
(
eventlog
.
LdJSONFormatter
)
rotateConf
:=
eventlog
.
LogRotatorConfig
{
Filename
:
path
.
Join
(
repoPath
,
"logs"
,
"events.log"
),
Filename
:
path
.
Join
(
repoPath
,
"logs"
,
"events.log"
),
MaxSizeMB
:
c
.
Log
.
MaxSizeMB
,
MaxBackups
:
c
.
Log
.
MaxBackups
,
MaxAgeDays
:
c
.
Log
.
MaxAgeDays
,
}
eventlog
.
Configure
(
eventlog
.
OutputRotatingLogFile
(
rotateConf
))
return
nil
}
var
_
Component
=
&
EventlogComponent
{}
repo/fsrepo/fsrepo.go
浏览文件 @
454cd454
...
...
@@ -316,14 +316,15 @@ func (r *FSRepo) components() []component.Component {
func
componentBuilders
()
[]
componentBuilder
{
return
[]
componentBuilder
{
// ConfigComponent
// ConfigComponent must be initialized first because other components
// depend on it.
componentBuilder
{
Init
:
component
.
InitConfigComponent
,
IsInitialized
:
component
.
ConfigComponentIsInitialized
,
OpenHandler
:
func
(
r
*
FSRepo
)
error
{
c
:=
component
.
ConfigComponent
{}
c
.
SetPath
(
r
.
path
)
if
err
:=
c
.
Open
();
err
!=
nil
{
if
err
:=
c
.
Open
(
nil
);
err
!=
nil
{
return
err
}
r
.
configComponent
=
c
...
...
@@ -338,7 +339,7 @@ func componentBuilders() []componentBuilder {
OpenHandler
:
func
(
r
*
FSRepo
)
error
{
c
:=
component
.
DatastoreComponent
{}
c
.
SetPath
(
r
.
path
)
if
err
:=
c
.
Open
();
err
!=
nil
{
if
err
:=
c
.
Open
(
r
.
configComponent
.
Config
()
);
err
!=
nil
{
return
err
}
r
.
datastoreComponent
=
c
...
...
@@ -353,7 +354,7 @@ func componentBuilders() []componentBuilder {
OpenHandler
:
func
(
r
*
FSRepo
)
error
{
c
:=
component
.
EventlogComponent
{}
c
.
SetPath
(
r
.
path
)
if
err
:=
c
.
Open
();
err
!=
nil
{
if
err
:=
c
.
Open
(
r
.
configComponent
.
Config
()
);
err
!=
nil
{
return
err
}
r
.
eventlogComponent
=
c
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论