window

package
v1.8.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseHealthCheckSource

type BaseHealthCheckSource struct {
	// contains filtered or unexported fields
}

BaseHealthCheckSource is a HealthCheckSource that polls a TimeWindowedStore. It returns a HealthStatus created using an ItemsToCheckFn.

func MustNewBaseHealthCheckSource

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.

func (*BaseHealthCheckSource) HealthStatus

HealthStatus polls the items inside the window and creates a HealthStatus using the ItemsToCheckFn.

func (*BaseHealthCheckSource) Submit

func (b *BaseHealthCheckSource) Submit(item interface{})

Submit submits an item.

type HealthyIfNotAllErrorsSource

type HealthyIfNotAllErrorsSource struct {
	// contains filtered or unexported fields
}

HealthyIfNotAllErrorsSource is a HealthCheckSource that polls a TimeWindowedStore. It returns, if there are only non-nil errors, the first non-nil error as an unhealthy check. If there are no items, returns healthy.

func MustNewHealthyIfNotAllErrorsSource

func MustNewHealthyIfNotAllErrorsSource(checkType health.CheckType, windowSize time.Duration) *HealthyIfNotAllErrorsSource

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 NewHealthyIfNotAllErrorsSource

func NewHealthyIfNotAllErrorsSource(checkType health.CheckType, windowSize time.Duration) (*HealthyIfNotAllErrorsSource, 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 (*HealthyIfNotAllErrorsSource) HealthStatus

HealthStatus polls the items inside the window and creates the HealthStatus.

func (*HealthyIfNotAllErrorsSource) Submit

func (h *HealthyIfNotAllErrorsSource) Submit(err error)

Submit submits an error.

type ItemWithTimestamp

type ItemWithTimestamp struct {
	Time time.Time
	Item interface{}
}

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 MultiKeyHealthyIfNotAllErrorsSource

type MultiKeyHealthyIfNotAllErrorsSource struct {
	// contains filtered or unexported fields
}

MultiKeyHealthyIfNotAllErrorsSource is a HealthCheckSource that polls a TimeWindowedStore. It returns unhealthy if there is at least one key with only non-nil errors. The Params field of the HealthCheckResult is the first error message for each key mapped by the key for all unhealthy keys. If there are no items, returns healthy.

func MustNewMultiKeyHealthyIfNotAllErrorsSource

func MustNewMultiKeyHealthyIfNotAllErrorsSource(checkType health.CheckType, messageInCaseOfError string, windowSize time.Duration) *MultiKeyHealthyIfNotAllErrorsSource

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 NewMultiKeyHealthyIfNotAllErrorsSource

func NewMultiKeyHealthyIfNotAllErrorsSource(checkType health.CheckType, messageInCaseOfError string, windowSize time.Duration) (*MultiKeyHealthyIfNotAllErrorsSource, 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 (*MultiKeyHealthyIfNotAllErrorsSource) HealthStatus

HealthStatus polls the items inside the window and creates the HealthStatus.

func (*MultiKeyHealthyIfNotAllErrorsSource) Submit

func (m *MultiKeyHealthyIfNotAllErrorsSource) Submit(key string, err error)

Submit submits an item as a key error pair.

type MultiKeyUnhealthyIfAtLeastOneErrorSource

type MultiKeyUnhealthyIfAtLeastOneErrorSource struct {
	// contains filtered or unexported fields
}

MultiKeyUnhealthyIfAtLeastOneErrorSource is a HealthCheckSource that polls a TimeWindowedStore. It returns unhealthy if there is a non-nil error for at least one key. The Params field of the HealthCheckResult is the first error message for each key mapped by the key for all unhealthy keys. If there are no items, returns healthy.

func MustNewMultiKeyUnhealthyIfAtLeastOneErrorSource

func MustNewMultiKeyUnhealthyIfAtLeastOneErrorSource(checkType health.CheckType, messageInCaseOfError string, windowSize time.Duration) *MultiKeyUnhealthyIfAtLeastOneErrorSource

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 NewMultiKeyUnhealthyIfAtLeastOneErrorSource

func NewMultiKeyUnhealthyIfAtLeastOneErrorSource(checkType health.CheckType, messageInCaseOfError string, windowSize time.Duration) (*MultiKeyUnhealthyIfAtLeastOneErrorSource, 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.

func (*MultiKeyUnhealthyIfAtLeastOneErrorSource) HealthStatus

HealthStatus polls the items inside the window and creates the HealthStatus.

func (*MultiKeyUnhealthyIfAtLeastOneErrorSource) Submit

Submit submits an item as a key error pair.

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 UnhealthyIfAtLeastOneErrorSource

type UnhealthyIfAtLeastOneErrorSource struct {
	// contains filtered or unexported fields
}

UnhealthyIfAtLeastOneErrorSource is a HealthCheckSource that polls a TimeWindowedStore. It returns the first non-nil error as an unhealthy check. If there are no items, returns healthy.

func MustNewUnhealthyIfAtLeastOneErrorSource

func MustNewUnhealthyIfAtLeastOneErrorSource(checkType health.CheckType, windowSize time.Duration) *UnhealthyIfAtLeastOneErrorSource

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 NewUnhealthyIfAtLeastOneErrorSource

func NewUnhealthyIfAtLeastOneErrorSource(checkType health.CheckType, windowSize time.Duration) (*UnhealthyIfAtLeastOneErrorSource, 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.

func (*UnhealthyIfAtLeastOneErrorSource) HealthStatus

HealthStatus polls the items inside the window and creates the HealthStatus.

func (*UnhealthyIfAtLeastOneErrorSource) Submit

func (u *UnhealthyIfAtLeastOneErrorSource) Submit(err error)

Submit submits an error.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL