master
Bel LaPointe 2025-05-24 14:13:18 -06:00
parent 739e832222
commit 3f7c13a6be
1 changed files with 8 additions and 0 deletions

View File

@ -27,12 +27,19 @@ type Scheduler struct {
type semaphored struct { type semaphored struct {
job cron.Job job cron.Job
ch chan struct{} ch chan struct{}
l logger.Logger
} }
func (s semaphored) Run() { func (s semaphored) Run() {
s.l.Info("scheduler.semaphored.Run() | acquiring...")
s.ch <- struct{}{} s.ch <- struct{}{}
s.l.Info("scheduler.semaphored.Run() | acquired")
s.job.Run() s.job.Run()
s.l.Info("scheduler.semaphored.Run() | releasing...")
<-s.ch <-s.ch
s.l.Info("scheduler.semaphored.Run() | released")
} }
func New() *Scheduler { func New() *Scheduler {
@ -46,6 +53,7 @@ func New() *Scheduler {
cron.Recover(l), cron.Recover(l),
func(j cron.Job) cron.Job { func(j cron.Job) cron.Job {
return semaphored{ return semaphored{
l: l,
job: j, job: j,
ch: semaphore, ch: semaphore,
} }