circuitbreaker

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2023 License: MIT Imports: 1 Imported by: 56

README

Breaker

Algorithms

Documentation

Overview

Example

This is a example of using a circuit breaker Do() when return nil.

package main

import (
	"fmt"

	"github.com/go-kratos/aegis/circuitbreaker/sre"
)

func main() {
	b := sre.NewBreaker()
	for i := 0; i < 1000; i++ {
		b.MarkSuccess()
	}
	for i := 0; i < 100; i++ {
		b.MarkFailed()
	}

	err := b.Allow()
	fmt.Printf("err=%v", err)
}
Output:

err=<nil>

Index

Examples

Constants

This section is empty.

Variables

View Source
var ErrNotAllowed = errors.New("circuitbreaker: not allowed for circuit open")

ErrNotAllowed error not allowed.

Functions

This section is empty.

Types

type CircuitBreaker

type CircuitBreaker interface {
	Allow() error
	MarkSuccess()
	MarkFailed()
}

CircuitBreaker is a circuit breaker.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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