Skip to content

Commit

Permalink
Update ticker strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
vit1251 committed Oct 7, 2020
1 parent 83e69c1 commit fe6c121
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ require (
golang.org/x/exp v0.0.0-20200924195034-c827fd4f18b9 // indirect
golang.org/x/image v0.0.0-20200927104501-e162460cd6b5 // indirect
golang.org/x/mobile v0.0.0-20200801112145-973feb4309de // indirect
golang.org/x/sys v0.0.0-20201005065044-765f4ea38db3 // indirect
golang.org/x/sys v0.0.0-20201005172224-997123666555 // indirect
golang.org/x/text v0.3.3
)
10 changes: 6 additions & 4 deletions pkg/mailer/MailerManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,20 @@ func (self *MailerManager) Start() {
}

func (self *MailerManager) run() {
var procIteration int
tick := time.NewTicker(5 * time.Minute)
for alive := true; alive; {
timer := time.NewTimer(5 * time.Minute)
select {
case <-self.event:
case <-timer.C:
log.Printf("Mailer start")
case <-tick.C:
procIteration += 1
log.Printf("Mailer start (%d)", procIteration)
self.AudioManager.Play("sess_start.mp3")
if err := self.processMailer(); err != nil {
log.Printf("err = %+v", err)
}
self.AudioManager.Play("sess_stop.mp3")
log.Printf("Mailer complete")
log.Printf("Mailer complete (%d)", procIteration)
}
}
}
Expand Down
20 changes: 14 additions & 6 deletions pkg/tosser/TosserManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,26 @@ func (self *TosserManager) Start() {
self.event <- true
}

func (self *TosserManager) processTosser() {
newTosser := NewTosser(self.Container)
newTosser.Toss()
}

func (self *TosserManager) run() {
log.Printf(" * Tosser service start")
var procIteration int
tick := time.NewTicker(1 * time.Minute)
for alive := true; alive; {
timer := time.NewTimer(150 * time.Second)
select {
case <-timer.C:
case <-self.event:
log.Printf(" * Tosser start")
newTosser := NewTosser(self.Container)
newTosser.Toss()
log.Printf(" * Tosser complete")
case <-tick.C:
procIteration += 1
log.Printf(" * Tosser start (%d)", procIteration)
self.processTosser()
log.Printf(" * Tosser complete (%d)", procIteration)
}
}
log.Printf(" * Tosser service stop")
}

func (self *TosserManager) makePacketName() string {
Expand Down

0 comments on commit fe6c121

Please sign in to comment.