github.com/v2pro/plz@v0.0.0-20221028024117-e5f9aec5b631/countlog/output/rotation/trigger_by_interval.go (about) 1 package rotation 2 3 import ( 4 "os" 5 "time" 6 "github.com/v2pro/plz/clock" 7 ) 8 9 type TriggerByInterval struct { 10 Interval time.Duration 11 } 12 13 func (trigger *TriggerByInterval) UpdateStat(stat interface{}, file *os.File, buf []byte) (interface{}, bool, error) { 14 return stat, false, nil 15 } 16 17 func (trigger *TriggerByInterval) TimeToTrigger() time.Duration { 18 epoch := clock.Now().Unix() 19 return trigger.Interval - (time.Duration(epoch) * time.Second) % trigger.Interval 20 }