Update codes

This commit is contained in:
Edward 2020-05-08 16:56:21 +08:00
parent 7762e0440f
commit 41d70fee70
2 changed files with 4 additions and 8 deletions

View File

@ -1,4 +1,3 @@
// Package breaker implements the circuit-breaker resiliency pattern for Go.
package breaker package breaker
import ( import (

View File

@ -12,12 +12,9 @@ var (
FailureThreshold = 10 FailureThreshold = 10
) )
//State of current switch
type State int
//State of current switch //State of current switch
const ( const (
UnknownState State = iota UnknownState uint = iota
FailureState FailureState
SuccessState SuccessState
) )
@ -27,19 +24,19 @@ type Circuit func(context.Context) error
//Counter interface //Counter interface
type Counter interface { type Counter interface {
Count(State) Count(uint)
ConsecutiveFailures() uint32 ConsecutiveFailures() uint32
LastActivity() time.Time LastActivity() time.Time
Reset() Reset()
} }
type counters struct { type counters struct {
state State state uint
lastActivity time.Time lastActivity time.Time
counts uint32 //counts of failures counts uint32 //counts of failures
} }
func (c *counters) Count(State) { func (c *counters) Count(state uint) {
} }