The cron actor now respects --fast-timing
This commit is contained in:
parent
70dc9702bd
commit
e21cd9ed11
4
cron.go
4
cron.go
@ -7,6 +7,7 @@ import "context"
|
|||||||
// tasks on time intervals.
|
// tasks on time intervals.
|
||||||
type cron struct {
|
type cron struct {
|
||||||
trimFunc func() bool
|
trimFunc func() bool
|
||||||
|
fastTiming bool
|
||||||
timing struct {
|
timing struct {
|
||||||
trimInterval time.Duration
|
trimInterval time.Duration
|
||||||
}
|
}
|
||||||
@ -28,6 +29,9 @@ func (this *cron) Configure (config Config) error {
|
|||||||
}
|
}
|
||||||
this.timing.trimInterval = value
|
this.timing.trimInterval = value
|
||||||
}
|
}
|
||||||
|
if this.fastTiming {
|
||||||
|
this.timing.trimInterval = time.Second * 10
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ type environment struct {
|
|||||||
done context.CancelCauseFunc
|
done context.CancelCauseFunc
|
||||||
group sync.WaitGroup
|
group sync.WaitGroup
|
||||||
conf MutableConfig
|
conf MutableConfig
|
||||||
|
cron *cron
|
||||||
|
|
||||||
// flags stores information from built-in flags.
|
// flags stores information from built-in flags.
|
||||||
flags struct {
|
flags struct {
|
||||||
@ -81,10 +82,11 @@ func (this *environment) Run(name, description string, actors ...Actor) {
|
|||||||
this.name = name
|
this.name = name
|
||||||
this.description = description
|
this.description = description
|
||||||
this.actors = usync.NewRWMonitor(&actorSets { })
|
this.actors = usync.NewRWMonitor(&actorSets { })
|
||||||
this.addToSets(actors...)
|
this.cron = &cron {
|
||||||
this.addToSets(&cron {
|
|
||||||
trimFunc: this.phase70_5Trimming,
|
trimFunc: this.phase70_5Trimming,
|
||||||
})
|
}
|
||||||
|
this.addToSets(actors...)
|
||||||
|
this.addToSets(this.cron)
|
||||||
|
|
||||||
if !this.phase10FlagParsing() { os.Exit(2) }
|
if !this.phase10FlagParsing() { os.Exit(2) }
|
||||||
if !this.phase13PidFileCreation() { os.Exit(1) }
|
if !this.phase13PidFileCreation() { os.Exit(1) }
|
||||||
@ -438,8 +440,7 @@ func (this *environment) applyConfig() error {
|
|||||||
if err != nil { return err }
|
if err != nil { return err }
|
||||||
|
|
||||||
if this.flags.fastTiming {
|
if this.flags.fastTiming {
|
||||||
this.timing.shutdownTimeout.Store(this.timing.shutdownTimeout.Load() / 60)
|
this.timing.shutdownTimeout.Store(time.Second * 10)
|
||||||
// TODO: quicken trim interval
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user