github.com/mhilton/juju-juju@v0.0.0-20150901100907-a94dd2c73455/worker/uniter/status.go (about)

     1  // Copyright 2015 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package uniter
     5  
     6  import (
     7  	"time"
     8  )
     9  
    10  const (
    11  	// interval at which the unit's status should be polled
    12  	statusPollInterval = 5 * time.Minute
    13  )
    14  
    15  // updateStatusSignal returns a time channel that fires after a given interval.
    16  func updateStatusSignal(now, lastSignal time.Time, interval time.Duration) <-chan time.Time {
    17  	waitDuration := interval - now.Sub(lastSignal)
    18  	return time.After(waitDuration)
    19  }
    20  
    21  // NewUpdateStatusTimer returns a timed signal suitable for update-status hook.
    22  func NewUpdateStatusTimer() TimedSignal {
    23  	return updateStatusSignal
    24  }