add punchy.respond_delay config option (#721)

This commit is contained in:
Wade Simmons 2023-03-29 15:32:35 -04:00 committed by GitHub
parent 8a82e0fb16
commit 3e5c7e6860
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 6 deletions

View file

@ -9,10 +9,11 @@ import (
)
type Punchy struct {
punch atomic.Bool
respond atomic.Bool
delay atomic.Int64
l *logrus.Logger
punch atomic.Bool
respond atomic.Bool
delay atomic.Int64
respondDelay atomic.Int64
l *logrus.Logger
}
func NewPunchyFromConfig(l *logrus.Logger, c *config.C) *Punchy {
@ -65,6 +66,12 @@ func (p *Punchy) reload(c *config.C, initial bool) {
p.l.Infof("punchy.delay changed to %s", p.GetDelay())
}
}
if initial || c.HasChanged("punchy.respond_delay") {
p.respondDelay.Store((int64)(c.GetDuration("punchy.respond_delay", 5*time.Second)))
if !initial {
p.l.Infof("punchy.respond_delay changed to %s", p.GetRespondDelay())
}
}
}
func (p *Punchy) GetPunch() bool {
@ -78,3 +85,7 @@ func (p *Punchy) GetRespond() bool {
func (p *Punchy) GetDelay() time.Duration {
return (time.Duration)(p.delay.Load())
}
func (p *Punchy) GetRespondDelay() time.Duration {
return (time.Duration)(p.respondDelay.Load())
}