mirror of
https://github.com/crazybber/go-pattern-examples.git
synced 2025-02-16 17:23:15 +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
|
package breaker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -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) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user