github.com/blend/go-sdk@v1.20220411.3/breaker/state.go (about) 1 /* 2 3 Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file. 5 6 */ 7 8 package breaker 9 10 import ( 11 "fmt" 12 ) 13 14 // These constants are states of CircuitBreaker. 15 const ( 16 StateClosed State = iota 17 StateHalfOpen 18 StateOpen 19 ) 20 21 // State is a type that represents a state of CircuitBreaker. 22 type State int 23 24 // String implements stringer interface. 25 func (s State) String() string { 26 switch s { 27 case StateClosed: 28 return "closed" 29 case StateHalfOpen: 30 return "half-open" 31 case StateOpen: 32 return "open" 33 default: 34 return fmt.Sprintf("unknown state: %d", s) 35 } 36 }