diff --git a/metric/system/system_windows.go b/metric/system/system_windows.go index b79a4056e..a1d3e3b9f 100644 --- a/metric/system/system_windows.go +++ b/metric/system/system_windows.go @@ -14,7 +14,7 @@ import ( . "github.com/qiniu/logkit/utils/models" ) -// KeySystemUsages TypeMetricSystem的字段名称 +// WinSystemUsages TypeMetricSystem 的字段名称 var WinSystemUsages = KeyValueSlice{ {KeySystemLoad1, "1分钟平均load值", ""}, {KeySystemLoad5, "5分钟平均load值", ""}, @@ -25,6 +25,7 @@ var WinSystemUsages = KeyValueSlice{ {KeySystemUptimeFormat, "格式化的系统启动时间", ""}, } +// WinSystemStats SystemStats type WinSystemStats struct { SystemStats } diff --git a/reader/tailx/tailx.go b/reader/tailx/tailx.go index f3b72309e..19e788ed3 100644 --- a/reader/tailx/tailx.go +++ b/reader/tailx/tailx.go @@ -101,6 +101,7 @@ type Result struct { logpath string } +// NewActiveReader construct ActiveReader func NewActiveReader(originPath, realPath, whence, inode string, r *Reader) (ar *ActiveReader, err error) { rpath := strings.Replace(realPath, string(os.PathSeparator), "_", -1) if runtime.GOOS == "windows" { @@ -158,6 +159,7 @@ func NewActiveReader(originPath, realPath, whence, inode string, r *Reader) (ar } +// Start ActiveReader func (ar *ActiveReader) Start() { if atomic.LoadInt32(&ar.status) == StatusRunning { log.Warnf("Runner[%s] ActiveReader %s was already running", ar.runnerName, ar.originpath) @@ -185,6 +187,7 @@ func (ar *ActiveReader) Start() { go ar.Run() } +// Stop ActiveReader func (ar *ActiveReader) Stop() error { if atomic.LoadInt32(&ar.status) == StatusStopped { return nil @@ -222,6 +225,7 @@ func (ar *ActiveReader) Stop() error { return nil } +// Run ActiveReader func (ar *ActiveReader) Run() { if !atomic.CompareAndSwapInt32(&ar.status, StatusInit, StatusRunning) { if !IsSelfRunner(ar.runnerName) { @@ -329,6 +333,7 @@ func (ar *ActiveReader) hasStopped() bool { return atomic.LoadInt32(&ar.status) == StatusStopped } +// Close ActiveReader func (ar *ActiveReader) Close() error { defer func() { if !IsSelfRunner(ar.runnerName) { @@ -367,16 +372,19 @@ func (ar *ActiveReader) sendError(err error) { ar.errChan <- err } +// Status get ActiveReader status func (ar *ActiveReader) Status() StatsInfo { ar.statsLock.RLock() defer ar.statsLock.RUnlock() return ar.stats } +// Lag get ActiveReader lag func (ar *ActiveReader) Lag() (rl *LagInfo, err error) { return ar.br.Lag() } +// SyncMeta sync ActiveReader meta //除了sync自己的bufreader,还要sync一行linecache func (ar *ActiveReader) SyncMeta() string { ar.cacheLineMux.Lock() @@ -385,6 +393,7 @@ func (ar *ActiveReader) SyncMeta() string { return ar.readcache } +// ReadDone implement OnceReader func (ar *ActiveReader) ReadDone() bool { return ar.br.ReadDone() } @@ -413,6 +422,7 @@ func (ar *ActiveReader) expired(expire time.Duration) bool { return false } +// NewReader construct reader.Reader func NewReader(meta *reader.Meta, conf conf.MapConf) (reader.Reader, error) { logPathPattern, err := conf.GetString(KeyLogPath) if err != nil { @@ -514,10 +524,12 @@ func (r *Reader) hasStopped() bool { return atomic.LoadInt32(&r.status) == StatusStopped } +// Name implements Reader interface func (r *Reader) Name() string { return "TailxReader: " + r.logPathPattern } +// SetMode implements Reader interface func (r *Reader) SetMode(mode string, value interface{}) error { reg, err := reader.HeadPatternMode(mode, value) if err != nil { @@ -529,6 +541,7 @@ func (r *Reader) SetMode(mode string, value interface{}) error { return nil } +// SetRunTime set run time func (r *Reader) SetRunTime(mode string, value interface{}) error { runTime, err := reader.ParseRunTimeWithMode(mode, value) if err != nil {