37 lines
653 B
Go
37 lines
653 B
Go
|
package service
|
||
|
|
||
|
import (
|
||
|
"sync"
|
||
|
"time"
|
||
|
|
||
|
"git.vbrandl.net/vbrandl/go-web-template/common"
|
||
|
)
|
||
|
|
||
|
type Service struct {
|
||
|
BackgroundJobsStarted bool
|
||
|
ServiceMutex sync.Mutex
|
||
|
StartTime time.Time
|
||
|
Config common.Config
|
||
|
}
|
||
|
|
||
|
func New(config common.Config) *Service {
|
||
|
ser := &Service{
|
||
|
BackgroundJobsStarted: false,
|
||
|
ServiceMutex: sync.Mutex{},
|
||
|
StartTime: time.Now(),
|
||
|
Config: config,
|
||
|
}
|
||
|
|
||
|
ser.StartBackground()
|
||
|
return ser
|
||
|
}
|
||
|
|
||
|
func (ser *Service) StartBackground() {
|
||
|
ser.ServiceMutex.Lock()
|
||
|
defer ser.ServiceMutex.Unlock()
|
||
|
|
||
|
ser.BackgroundJobsStarted = true
|
||
|
|
||
|
// TODO: start jobs
|
||
|
}
|