simplelogic

package
v3.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2022 License: Apache-2.0 Imports: 3 Imported by: 3

Documentation

Overview

Package simplelogic is a holding place for close and open circuit logic that is otherwise simple in use or complexity.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConsecutiveErrOpenerFactory

func ConsecutiveErrOpenerFactory(config ConfigConsecutiveErrOpener) func() circuit.ClosedToOpen

ConsecutiveErrOpenerFactory constructs a new ConsecutiveErrOpener

Types

type ConfigConsecutiveErrOpener

type ConfigConsecutiveErrOpener struct {
	ErrorThreshold int64
}

ConfigConsecutiveErrOpener configures a ConsecutiveErrOpener

func (*ConfigConsecutiveErrOpener) Merge

Merge this config with another

type ConsecutiveErrOpener

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

ConsecutiveErrOpener is simple closed->open logic that opens on consecutive error counts

func (*ConsecutiveErrOpener) Closed

func (c *ConsecutiveErrOpener) Closed(_ time.Time)

Closed resets the consecutive error count

func (*ConsecutiveErrOpener) ErrBadRequest

func (c *ConsecutiveErrOpener) ErrBadRequest(now time.Time, duration time.Duration)

ErrBadRequest is ignored

func (*ConsecutiveErrOpener) ErrConcurrencyLimitReject

func (c *ConsecutiveErrOpener) ErrConcurrencyLimitReject(now time.Time)

ErrConcurrencyLimitReject is ignored

func (*ConsecutiveErrOpener) ErrFailure

func (c *ConsecutiveErrOpener) ErrFailure(now time.Time, duration time.Duration)

ErrFailure increments the consecutive error counter

func (*ConsecutiveErrOpener) ErrInterrupt

func (c *ConsecutiveErrOpener) ErrInterrupt(now time.Time, duration time.Duration)

ErrInterrupt is ignored

func (*ConsecutiveErrOpener) ErrShortCircuit

func (c *ConsecutiveErrOpener) ErrShortCircuit(now time.Time)

ErrShortCircuit is ignored

func (*ConsecutiveErrOpener) ErrTimeout

func (c *ConsecutiveErrOpener) ErrTimeout(now time.Time, duration time.Duration)

ErrTimeout increments the consecutive error counter

func (*ConsecutiveErrOpener) Opened

func (c *ConsecutiveErrOpener) Opened(now time.Time)

Opened resets the error counter

func (*ConsecutiveErrOpener) Prevent

func (c *ConsecutiveErrOpener) Prevent(now time.Time) bool

Prevent always returns false

func (*ConsecutiveErrOpener) SetConfigNotThreadSafe

func (c *ConsecutiveErrOpener) SetConfigNotThreadSafe(props ConfigConsecutiveErrOpener)

SetConfigNotThreadSafe updates the error threshold

func (*ConsecutiveErrOpener) SetConfigThreadSafe

func (c *ConsecutiveErrOpener) SetConfigThreadSafe(props ConfigConsecutiveErrOpener)

SetConfigThreadSafe updates the error threshold

func (*ConsecutiveErrOpener) ShouldOpen

func (c *ConsecutiveErrOpener) ShouldOpen(now time.Time) bool

ShouldOpen returns true if enough consecutive errors have returned

func (*ConsecutiveErrOpener) Success

func (c *ConsecutiveErrOpener) Success(now time.Time, duration time.Duration)

Success resets the consecutive error count

Jump to

Keyboard shortcuts

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