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 ¶
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 ¶
func (hc HealthClient) Check(ctx context.Context, req *grpc_health_v1.HealthCheckRequest, opts ...grpc.CallOption) (*grpc_health_v1.HealthCheckResponse, error)
Check circuit breaks the health check if write or read error thresholds have been reached. If not, it performs the health check.