Skip to content

Commit

Permalink
go lint
Browse files Browse the repository at this point in the history
  • Loading branch information
redHJ committed Apr 10, 2019
1 parent 43d2249 commit b757f41
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion metric/system/system_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
. "github.com/qiniu/logkit/utils/models"
)

// KeySystemUsages TypeMetricSystem的字段名称
// WinSystemUsages TypeMetricSystem 的字段名称
var WinSystemUsages = KeyValueSlice{
{KeySystemLoad1, "1分钟平均load值", ""},
{KeySystemLoad5, "5分钟平均load值", ""},
Expand All @@ -25,6 +25,7 @@ var WinSystemUsages = KeyValueSlice{
{KeySystemUptimeFormat, "格式化的系统启动时间", ""},
}

// WinSystemStats SystemStats
type WinSystemStats struct {
SystemStats
}
Expand Down
13 changes: 13 additions & 0 deletions reader/tailx/tailx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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()
Expand All @@ -385,6 +393,7 @@ func (ar *ActiveReader) SyncMeta() string {
return ar.readcache
}

// ReadDone implement OnceReader
func (ar *ActiveReader) ReadDone() bool {
return ar.br.ReadDone()
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit b757f41

Please sign in to comment.