From 41d70fee7031d047e9f3786c5ff754ccf461fd00 Mon Sep 17 00:00:00 2001 From: Edward Date: Fri, 8 May 2020 16:56:21 +0800 Subject: [PATCH] Update codes --- gomore/06_circuit_breaker/breaker/breaker.go | 1 - gomore/06_circuit_breaker/circuit_breaker.go | 11 ++++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/gomore/06_circuit_breaker/breaker/breaker.go b/gomore/06_circuit_breaker/breaker/breaker.go index f88ca72..f344442 100644 --- a/gomore/06_circuit_breaker/breaker/breaker.go +++ b/gomore/06_circuit_breaker/breaker/breaker.go @@ -1,4 +1,3 @@ -// Package breaker implements the circuit-breaker resiliency pattern for Go. package breaker import ( diff --git a/gomore/06_circuit_breaker/circuit_breaker.go b/gomore/06_circuit_breaker/circuit_breaker.go index 5bd7b4d..701cc99 100644 --- a/gomore/06_circuit_breaker/circuit_breaker.go +++ b/gomore/06_circuit_breaker/circuit_breaker.go @@ -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) { }