resiliency

package
v0.0.0-...-bfab8ab Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: BSD-3-Clause Imports: 9 Imported by: 1

Documentation

Overview

Example (RunTest)
idiomaticGo := true
quit := make(chan struct{}, 1)
status := make(chan *runtime.Status, 100)
//cb, _ := NewStatusCircuitBreaker( 100, 100, 0, func(s *runtime.Status) bool { return s.OK() })

//go run(createTable(), func(ctx context.Context) *runtime.Status { return runtime.NewStatusOK() }, 0, cb, quit, status)
if idiomaticGo {
	done := make(chan struct{})
	go func(chan struct{}, chan *runtime.Status) {
		for {
			select {
			case st := <-status:
				if st.IsContent() {
					fmt.Printf("test: runTest() -> %v", st.ContentString())
				}
				if st.OK() {
					done <- struct{}{}
					return
				}
			default:
			}
		}
	}(done, status)
	<-done
	close(done)
} else {
	// idiomatic Java
	time.Sleep(time.Minute * 1)
	quit <- struct{}{}
	s := <-status
	if s != nil && s.IsContent() {
		fmt.Printf("test: runTest() -> %v\n", s.ContentString())
	}
	//for s := range status {
	//		}
	//	}
}
close(quit)
close(status)
Output:

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	PkgUri = reflect.TypeOf(any(pkg{})).PkgPath()
)

Functions

func ControllerWrapRoundTripper

func ControllerWrapRoundTripper(rt http.RoundTripper) http.RoundTripper

ControllerWrapRoundTripper - provides a RoundTrip wrapper that applies egress controllers

func ControllerWrapTransport

func ControllerWrapTransport(client *http.Client)

ControllerWrapTransport - provides a RoundTrip wrapper that applies egress controllers

Types

type Controller

type Controller interface {
	Apply(r *http.Request, body any) (t any, status *runtime.Status)
}

Controller - an interface that manages resiliency for a runtime.TypeHandlerFn

func NewController

func NewController(name string, threshold Threshold, handler runtime.DoHandler, log startup.AccessLogFn) Controller

NewController - create a new resiliency controller

type StatusAgent

type StatusAgent interface {
	Run(quit <-chan struct{}, status chan *runtime.Status)
}

StatusAgent - an agent that will manage returning an endpoint back to receiving traffic

func NewStatusAgent

func NewStatusAgent(timeout time.Duration, ping pingFn, cb StatusCircuitBreaker) (StatusAgent, error)

NewStatusAgent - creation of an agent with configuration

type StatusCircuitBreaker

type StatusCircuitBreaker interface {
	Allow(status *runtime.Status) bool
	Limit() rate.Limit
	SetLimit(limit rate.Limit)
	Burst() int
	SetBurst(burst int)
}

StatusCircuitBreaker - Circuit breaker functionality based on a runtime.Status. Configuration provides the limit and burst for rate limiting, and a function to determine the selection of statuses.

func CloneStatusCircuitBreaker

func CloneStatusCircuitBreaker(cb StatusCircuitBreaker) StatusCircuitBreaker

CloneStatusCircuitBreaker - create a clone of a StatusCircuitBreaker

func NewStatusCircuitBreaker

func NewStatusCircuitBreaker(limit rate.Limit, burst int, timeout time.Duration, fn StatusSelectFn) (StatusCircuitBreaker, error)

NewStatusCircuitBreaker - create a circuit breaker with argument validation

type StatusSelectFn

type StatusSelectFn func(status *runtime.Status) bool

StatusSelectFn - typedef for a function that determines when to select a status

type Threshold

type Threshold struct {
	Timeout time.Duration
}

Threshold - timeout configuration

Jump to

Keyboard shortcuts

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