Documentation
¶
Index ¶
- type BaseHealthCheckSource
- type ErrorHealthCheckSource
- func MustNewHealthyIfNotAllErrorsSource(checkType health.CheckType, windowSize time.Duration) ErrorHealthCheckSource
- func MustNewUnhealthyIfAtLeastOneErrorSource(checkType health.CheckType, windowSize time.Duration) ErrorHealthCheckSource
- func NewHealthyIfNotAllErrorsSource(checkType health.CheckType, windowSize time.Duration) (ErrorHealthCheckSource, error)
- func NewUnhealthyIfAtLeastOneErrorSource(checkType health.CheckType, windowSize time.Duration) (ErrorHealthCheckSource, error)
- type ErrorSubmitter
- type ItemSubmitter
- type ItemWithTimestamp
- type ItemsToCheckFn
- type KeyedErrorHealthCheckSource
- func MustNewMultiKeyHealthyIfNotAllErrorsSource(checkType health.CheckType, messageInCaseOfError string, ...) KeyedErrorHealthCheckSource
- func MustNewMultiKeyUnhealthyIfAtLeastOneErrorSource(checkType health.CheckType, messageInCaseOfError string, ...) KeyedErrorHealthCheckSource
- func NewMultiKeyHealthyIfNotAllErrorsSource(checkType health.CheckType, messageInCaseOfError string, ...) (KeyedErrorHealthCheckSource, error)
- func NewMultiKeyUnhealthyIfAtLeastOneErrorSource(checkType health.CheckType, messageInCaseOfError string, ...) (KeyedErrorHealthCheckSource, error)
- type KeyedErrorSubmitter
- type TimeWindowedStore
- type TimedKey
- type TimedKeyStore
- type TimedKeys
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseHealthCheckSource ¶
type BaseHealthCheckSource interface { ItemSubmitter status.HealthCheckSource }
BaseHealthCheckSource determines health status based on user-submitted items.
func MustNewBaseHealthCheckSource ¶ added in v1.8.1
func MustNewBaseHealthCheckSource(windowSize time.Duration, itemsToCheckFn ItemsToCheckFn) BaseHealthCheckSource
MustNewBaseHealthCheckSource returns the result of calling NewBaseHealthCheckSource, but panics if it returns an error. Should only be used in instances where the inputs are statically defined and known to be valid.
func NewBaseHealthCheckSource ¶
func NewBaseHealthCheckSource(windowSize time.Duration, itemsToCheckFn ItemsToCheckFn) (BaseHealthCheckSource, error)
NewBaseHealthCheckSource creates a baseHealthCheckSource with a sliding window of size windowSize and uses the itemsToCheckFn. windowSize must be a positive value and itemsToCheckFn must not be nil, otherwise returns error.
type ErrorHealthCheckSource ¶ added in v1.11.1
type ErrorHealthCheckSource interface { ErrorSubmitter status.HealthCheckSource }
ErrorHealthCheckSource is a health check source with statuses determined by submitted errors.
func MustNewHealthyIfNotAllErrorsSource ¶ added in v1.8.1
func MustNewHealthyIfNotAllErrorsSource(checkType health.CheckType, windowSize time.Duration) ErrorHealthCheckSource
MustNewHealthyIfNotAllErrorsSource returns the result of calling NewHealthyIfNotAllErrorsSource, but panics if it returns an error. Should only be used in instances where the inputs are statically defined and known to be valid.
func MustNewUnhealthyIfAtLeastOneErrorSource ¶ added in v1.8.1
func MustNewUnhealthyIfAtLeastOneErrorSource(checkType health.CheckType, windowSize time.Duration) ErrorHealthCheckSource
MustNewUnhealthyIfAtLeastOneErrorSource returns the result of calling NewUnhealthyIfAtLeastOneErrorSource, but panics if it returns an error. Should only be used in instances where the inputs are statically defined and known to be valid.
func NewHealthyIfNotAllErrorsSource ¶
func NewHealthyIfNotAllErrorsSource(checkType health.CheckType, windowSize time.Duration) (ErrorHealthCheckSource, error)
NewHealthyIfNotAllErrorsSource creates an healthyIfNotAllErrorsSource with a sliding window of size windowSize and uses the checkType. windowSize must be a positive value, otherwise returns error.
func NewUnhealthyIfAtLeastOneErrorSource ¶
func NewUnhealthyIfAtLeastOneErrorSource(checkType health.CheckType, windowSize time.Duration) (ErrorHealthCheckSource, error)
NewUnhealthyIfAtLeastOneErrorSource creates an unhealthyIfAtLeastOneErrorSource with a sliding window of size windowSize and uses the checkType. windowSize must be a positive value, otherwise returns error.
type ErrorSubmitter ¶ added in v1.11.1
type ErrorSubmitter interface {
Submit(error)
}
ErrorSubmitter allows components whose functionality dictates a portion of health status to only consume this interface.
type ItemSubmitter ¶ added in v1.11.1
type ItemSubmitter interface {
Submit(interface{})
}
ItemSubmitter allows components of code whose functionality dictates health status to just consume this single-method interface.
type ItemWithTimestamp ¶
ItemWithTimestamp is a struct that stores an item and the time it was submitted.
type ItemsToCheckFn ¶
type ItemsToCheckFn func(ctx context.Context, items []ItemWithTimestamp) health.HealthCheckResult
ItemsToCheckFn is a function that constructs a HealthCheckResult from a set of items.
type KeyedErrorHealthCheckSource ¶ added in v1.11.1
type KeyedErrorHealthCheckSource interface { KeyedErrorSubmitter status.HealthCheckSource }
KeyedErrorHealthCheckSource is a health check source with statuses determined by submitted key error pairs.
func MustNewMultiKeyHealthyIfNotAllErrorsSource ¶ added in v1.8.1
func MustNewMultiKeyHealthyIfNotAllErrorsSource(checkType health.CheckType, messageInCaseOfError string, windowSize time.Duration) KeyedErrorHealthCheckSource
MustNewMultiKeyHealthyIfNotAllErrorsSource returns the result of calling NewMultiKeyHealthyIfNotAllErrorsSource, but panics if it returns an error. Should only be used in instances where the inputs are statically defined and known to be valid.
func MustNewMultiKeyUnhealthyIfAtLeastOneErrorSource ¶ added in v1.8.1
func MustNewMultiKeyUnhealthyIfAtLeastOneErrorSource(checkType health.CheckType, messageInCaseOfError string, windowSize time.Duration) KeyedErrorHealthCheckSource
MustNewMultiKeyUnhealthyIfAtLeastOneErrorSource returns the result of calling NewMultiKeyUnhealthyIfAtLeastOneErrorSource, but panics if it returns an error. Should only be used in instances where the inputs are statically defined and known to be valid.
func NewMultiKeyHealthyIfNotAllErrorsSource ¶
func NewMultiKeyHealthyIfNotAllErrorsSource(checkType health.CheckType, messageInCaseOfError string, windowSize time.Duration) (KeyedErrorHealthCheckSource, error)
NewMultiKeyHealthyIfNotAllErrorsSource creates an multiKeyUnhealthyIfAtLeastOneErrorSource with a sliding window of size windowSize and uses the checkType and a message in case of errors. windowSize must be a positive value, otherwise returns error.
func NewMultiKeyUnhealthyIfAtLeastOneErrorSource ¶
func NewMultiKeyUnhealthyIfAtLeastOneErrorSource(checkType health.CheckType, messageInCaseOfError string, windowSize time.Duration) (KeyedErrorHealthCheckSource, error)
NewMultiKeyUnhealthyIfAtLeastOneErrorSource creates an multiKeyUnhealthyIfAtLeastOneErrorSource with a sliding window of size windowSize and uses the checkType and a message in case of errors. windowSize must be a positive value, otherwise returns error.
type KeyedErrorSubmitter ¶ added in v1.11.1
KeyedErrorSubmitter allows components whose functionality dictates a portion of health status to only consume this interface.
type TimeWindowedStore ¶
type TimeWindowedStore struct {
// contains filtered or unexported fields
}
TimeWindowedStore is a thread-safe struct that stores submitted items and supports polling for all items submitted within the last windowSize period. When any operation is made, all out-of-date items are pruned out of memory.
func NewTimeWindowedStore ¶
func NewTimeWindowedStore(windowSize time.Duration) (*TimeWindowedStore, error)
NewTimeWindowedStore creates a new TimeWindowedStore with the provided windowSize. windowSize must be a positive value, otherwise returns error.
func (*TimeWindowedStore) GetWindowSize ¶
func (t *TimeWindowedStore) GetWindowSize() time.Duration
GetWindowSize returns the windowSize.
func (*TimeWindowedStore) ItemsInWindow ¶
func (t *TimeWindowedStore) ItemsInWindow() []ItemWithTimestamp
ItemsInWindow prunes all out-of-date items out of memory and then returns all up-to-date items. The returned slice is the one used internally and must not be modified.
func (*TimeWindowedStore) Submit ¶
func (t *TimeWindowedStore) Submit(item interface{})
Submit prunes all out-of-date items out of memory and then adds a new one.
type TimedKeyStore ¶ added in v1.11.2
type TimedKeyStore interface { // Put adds a new TimedKey to the end of the list with the timestamp set to the current time. // Adding an already present key will cause the current TimedKey to be updated to the current and to be sent to the end of the list. Put(key string) // Delete removes a TimedKey from the list. If the key doesn't exist, it is a no op. // The second return value returns whether or not the key existed within the store. Delete(key string) bool // Get returns the TimedKey associated with the provided key if it exists. Returns empty struct otherwise. // The second return value returns whether or not the key exists within the store. Get(key string) (TimedKey, bool) // Get returns a list of all stored TimedKeys in increasing order of timestamps. List() TimedKeys // Oldest returns the stored TimedKey with the oldest timestamp if it exists. Returns empty struct otherwise. // The second return value returns whether or not such element exist. Oldest() (TimedKey, bool) // Newest returns the stored TimedKey with the newest timestamp if it exists. Returns empty struct otherwise. // The second return value returns whether or not such element exist. Newest() (TimedKey, bool) }
TimedKeyStore is a list of keys ordered by the time they were added or updated. Each key is unique within the store. Adding an already present key will cause the time of the key to be updated to the current time. The position within the list will be updated accordingly.
func NewTimedKeyStore ¶ added in v1.11.2
func NewTimedKeyStore() TimedKeyStore
NewTimedKeyStore creates a TimedKeyStore that executes all operations in O(1) time except for List, which is O(n), where n is the number of stored keys. Memory consumption is O(n), where n is the number of stored keys. This struct is not thread safe.