justlog/archiver/archiver.go
2018-12-06 22:58:42 +01:00

35 lines
495 B
Go

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()
go a.startConsumer()
}
func (a *Archiver) startConsumer() {
for task := range a.workQueue {
a.gzipFile(task)
}
}
func (a *Archiver) startScanner() {
for {
a.scanLogPath()
time.Sleep(time.Second * 60)
}
}