justlog/archiver/archiver.go

36 lines
492 B
Go
Raw Normal View History

2018-12-06 22:58:42 +01:00
package archiver
import (
"time"
)
func NewArchiver(logPath string) *Archiver {
return &Archiver{
logPath: logPath,
workQueue: make(chan string),
}
}
type Archiver struct {
logPath string
workQueue chan string
}
func (a *Archiver) Boot() {
go a.startScanner()
a.startConsumer()
2018-12-06 22:58:42 +01:00
}
func (a *Archiver) startConsumer() {
for task := range a.workQueue {
a.gzipFile(task)
}
}
func (a *Archiver) startScanner() {
for {
a.scanLogPath()
time.Sleep(time.Second * 60)
}
}