tracker

package
v14.2.7 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2021 License: MIT Imports: 7 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, errorWindow time.Duration, readThreshold, writeThreshold uint32) (ErrorTracker, error)

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

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