justlog/archiver/archiver.go

35 lines
492 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()
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)
}
}