Documentation ¶
Index ¶
- Constants
- type HealthCheck
- func (hc *HealthCheck) Expires() time.Duration
- func (hc *HealthCheck) GetTimeout() time.Duration
- func (hc HealthCheck) MarshalJSON() ([]byte, error)
- func (hc *HealthCheck) NotRunning() HealthStatus
- func (hc *HealthCheck) Ping(cancel <-chan struct{}, key HealthStatusKey, report func(HealthStatus))
- func (hc *HealthCheck) Run(key HealthStatusKey) (stat HealthStatus)
- func (hc *HealthCheck) Unknown() HealthStatus
- func (hc *HealthCheck) UnmarshalJSON(data []byte) error
- func (hc HealthCheck) ValidEntity() error
- type HealthStatus
- type HealthStatusCache
- func (cache *HealthStatusCache) Delete(key HealthStatusKey)
- func (cache *HealthStatusCache) DeleteExpired()
- func (cache *HealthStatusCache) DeleteInstance(serviceID string, instanceID int)
- func (cache *HealthStatusCache) Get(key HealthStatusKey) (HealthStatus, bool)
- func (cache *HealthStatusCache) Set(key HealthStatusKey, value HealthStatus, expire time.Duration)
- func (cache *HealthStatusCache) SetPurgeFrequency(interval time.Duration)
- func (cache *HealthStatusCache) Size() int
- type HealthStatusItem
- type HealthStatusKey
- type Status
Constants ¶
const ( // OK means health check is passing OK Status = 0 // Failed means health check is responsive, but failing Failed = 1 // Timeout means health check is non-responsive in the given time Timeout = 2 // Unknown means the instance hasn't checked in within the provided time // limit. Unknown = 3 // NotRunning means the instance is not running NotRunning = 4 )
const DefaultExpiration time.Duration = time.Minute
DefaultExpiration is the default expiration for deprecated health status updates.
const DefaultTimeout time.Duration = 30 * time.Second
DefaultTimeout is the default timeout setting used to determine when a health check is non-responsive
const DefaultTolerance int = 2
DefaultTolerance is the default coefficient used to determine when a health check is expired
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HealthCheck ¶
type HealthCheck struct { Script string Timeout time.Duration Interval time.Duration Tolerance int // Kill properties will kill the container if the observed error code is in the error code list // and this happens <count>-times. If the error codes list is empty and the kill count is >0, then any // non-zero error code will count toward the kill count. KillExitCodes []int KillCountLimit int KillCounter int }
HealthCheck is the health check object.
func (*HealthCheck) Expires ¶
func (hc *HealthCheck) Expires() time.Duration
Expires calculates the time to live on the cache item.
func (*HealthCheck) GetTimeout ¶
func (hc *HealthCheck) GetTimeout() time.Duration
GetTimeout returns the timeout duration.
func (HealthCheck) MarshalJSON ¶
func (hc HealthCheck) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaller
func (*HealthCheck) NotRunning ¶
func (hc *HealthCheck) NotRunning() HealthStatus
NotRunning returns the health status for a service instance that is not running.
func (*HealthCheck) Ping ¶
func (hc *HealthCheck) Ping(cancel <-chan struct{}, key HealthStatusKey, report func(HealthStatus))
Ping performs the health check on the specified interval.
func (*HealthCheck) Run ¶
func (hc *HealthCheck) Run(key HealthStatusKey) (stat HealthStatus)
Run returns the health status as a result of running the health check script.
func (*HealthCheck) Unknown ¶
func (hc *HealthCheck) Unknown() HealthStatus
Unknown returns the health status for a service instance whose health check response is unknown.
func (*HealthCheck) UnmarshalJSON ¶
func (hc *HealthCheck) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaller
func (HealthCheck) ValidEntity ¶
func (hc HealthCheck) ValidEntity() error
type HealthStatus ¶
HealthStatus is the output from a provided health check.
type HealthStatusCache ¶
type HealthStatusCache struct {
// contains filtered or unexported fields
}
HealthStatusCache keeps track of the health status items in memory.
func (*HealthStatusCache) Delete ¶
func (cache *HealthStatusCache) Delete(key HealthStatusKey)
Delete removes an item from the cache.
func (*HealthStatusCache) DeleteExpired ¶
func (cache *HealthStatusCache) DeleteExpired()
DeleteExpired removes all expired items from the cache.
func (*HealthStatusCache) DeleteInstance ¶
func (cache *HealthStatusCache) DeleteInstance(serviceID string, instanceID int)
DeleteInstance removes all health checks per instance.
func (*HealthStatusCache) Get ¶
func (cache *HealthStatusCache) Get(key HealthStatusKey) (HealthStatus, bool)
Get returns an item from the cache if it hasn't yet expired.
func (*HealthStatusCache) Set ¶
func (cache *HealthStatusCache) Set(key HealthStatusKey, value HealthStatus, expire time.Duration)
Set sets an item into the cache.
func (*HealthStatusCache) SetPurgeFrequency ¶
func (cache *HealthStatusCache) SetPurgeFrequency(interval time.Duration)
SetPurgeFrequency sets the autopurge interval for cache cleanup. Stops autopurge if interval is <= 0.
func (*HealthStatusCache) Size ¶
func (cache *HealthStatusCache) Size() int
Size returns the size of the cache.
type HealthStatusItem ¶
type HealthStatusItem struct {
// contains filtered or unexported fields
}
HealthStatusItem is an item stored in the health status cache.
func (*HealthStatusItem) Expired ¶
func (item *HealthStatusItem) Expired() bool
Expired returns true when a health status item has expired in the cache.
func (*HealthStatusItem) Value ¶
func (item *HealthStatusItem) Value() HealthStatus
Value returns the HealthStatus data
type HealthStatusKey ¶
HealthStatusKey is the key to the health status item in the cache.