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 ¶
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 ¶
ControllerWrapTransport - provides a RoundTrip wrapper that applies egress controllers
Types ¶
type Controller ¶
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 ¶
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 ¶
StatusSelectFn - typedef for a function that determines when to select a status