mirror of
https://github.com/crazybber/go-pattern-examples.git
synced 2024-11-22 11:56:03 +03:00
Update codes
This commit is contained in:
parent
7762e0440f
commit
41d70fee70
@ -1,4 +1,3 @@
|
||||
// Package breaker implements the circuit-breaker resiliency pattern for Go.
|
||||
package breaker
|
||||
|
||||
import (
|
||||
|
@ -12,12 +12,9 @@ var (
|
||||
FailureThreshold = 10
|
||||
)
|
||||
|
||||
//State of current switch
|
||||
type State int
|
||||
|
||||
//State of current switch
|
||||
const (
|
||||
UnknownState State = iota
|
||||
UnknownState uint = iota
|
||||
FailureState
|
||||
SuccessState
|
||||
)
|
||||
@ -27,19 +24,19 @@ type Circuit func(context.Context) error
|
||||
|
||||
//Counter interface
|
||||
type Counter interface {
|
||||
Count(State)
|
||||
Count(uint)
|
||||
ConsecutiveFailures() uint32
|
||||
LastActivity() time.Time
|
||||
Reset()
|
||||
}
|
||||
|
||||
type counters struct {
|
||||
state State
|
||||
state uint
|
||||
lastActivity time.Time
|
||||
counts uint32 //counts of failures
|
||||
}
|
||||
|
||||
func (c *counters) Count(State) {
|
||||
func (c *counters) Count(state uint) {
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user