tracker

package
v15.3.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorTracker

type ErrorTracker interface {
	// IncrReadErr increases read errors by 1
	IncrReadErr(nodeStorage string)
	// IncrWriteErr increases write errors by 1
	IncrWriteErr(nodeStorage string)
	// ReadThresholdReached returns whether or not the read threshold was reached
	ReadThresholdReached(nodeStorage string) bool
	// WriteThresholdReached returns whether or not the read threshold was reached
	WriteThresholdReached(nodeStorage string) bool
}

ErrorTracker allows tracking how many read/write errors have occurred, and whether or not it has exceeded a configured threshold in a configured time window

func NewErrors

func NewErrors(ctx context.Context, isInErrorWindow ErrorWindowFunction, readThreshold, writeThreshold uint32) (ErrorTracker, error)

NewErrors creates a new Error instance given a time window in seconds, and read and write thresholds

type ErrorWindowFunction

type ErrorWindowFunction func(now time.Time, errorTime time.Time) bool

ErrorWindowFunction is a function that is passed to `NewErrors()`. This function shall return `true` if the time when a specific error occurred should be considered part of the error window.

func NewErrorWindowFunction

func NewErrorWindowFunction(cfg config.Failover) (ErrorWindowFunction, error)

NewErrorWindowFunction derives an error window from the given configuration.

type HealthClient

type HealthClient struct {
	grpc_health_v1.HealthClient
	// contains filtered or unexported fields
}

HealthClient wraps a gRPC HealthClient and circuit breaks its health checks if the error threshold has been reached.

func NewHealthClient

func NewHealthClient(client grpc_health_v1.HealthClient, storage string, tracker ErrorTracker) HealthClient

NewHealthClient returns the HealthClient wrapped with error threshold circuit breaker.

func (HealthClient) Check

Check circuit breaks the health check if write or read error thresholds have been reached. If not, it performs the health check.

Jump to

Keyboard shortcuts

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