1
0
Fork 0

Add healthcheck interval

This commit is contained in:
Julien Salleyron 2017-02-06 22:59:50 +01:00 committed by Emile Vauge
parent 5e8805f24d
commit 6b6f010851
No known key found for this signature in database
GPG key ID: D808B4C167352E59
3 changed files with 24 additions and 6 deletions

View file

@ -26,6 +26,7 @@ func GetHealthCheck() *HealthCheck {
// BackendHealthCheck HealthCheck configuration for a backend
type BackendHealthCheck struct {
URL string
Interval time.Duration
DisabledURLs []*url.URL
lb loadBalancer
}
@ -49,8 +50,8 @@ func newHealthCheck() *HealthCheck {
}
// NewBackendHealthCheck Instantiate a new BackendHealthCheck
func NewBackendHealthCheck(URL string, lb loadBalancer) *BackendHealthCheck {
return &BackendHealthCheck{URL, nil, lb}
func NewBackendHealthCheck(URL string, interval time.Duration, lb loadBalancer) *BackendHealthCheck {
return &BackendHealthCheck{URL, interval, nil, lb}
}
//SetBackendsConfiguration set backends configuration
@ -70,7 +71,7 @@ func (hc *HealthCheck) execute(ctx context.Context) {
currentBackendID := backendID
safe.Go(func() {
for {
ticker := time.NewTicker(time.Second * 30)
ticker := time.NewTicker(currentBackend.Interval)
select {
case <-ctx.Done():
log.Debugf("Stopping all current Healthcheck goroutines")