github.com/hellobchain/third_party@v0.0.0-20230331131523-deb0478a2e52/hyperledger/fabric/common/metrics/metricsfakes/histogram.go (about) 1 // Code generated by counterfeiter. DO NOT EDIT. 2 package metricsfakes 3 4 import ( 5 "sync" 6 7 "github.com/hellobchain/third_party/hyperledger/fabric/common/metrics" 8 ) 9 10 type Histogram struct { 11 WithStub func(labelValues ...string) metrics.Histogram 12 withMutex sync.RWMutex 13 withArgsForCall []struct { 14 labelValues []string 15 } 16 withReturns struct { 17 result1 metrics.Histogram 18 } 19 withReturnsOnCall map[int]struct { 20 result1 metrics.Histogram 21 } 22 ObserveStub func(value float64) 23 observeMutex sync.RWMutex 24 observeArgsForCall []struct { 25 value float64 26 } 27 invocations map[string][][]interface{} 28 invocationsMutex sync.RWMutex 29 } 30 31 func (fake *Histogram) With(labelValues ...string) metrics.Histogram { 32 fake.withMutex.Lock() 33 ret, specificReturn := fake.withReturnsOnCall[len(fake.withArgsForCall)] 34 fake.withArgsForCall = append(fake.withArgsForCall, struct { 35 labelValues []string 36 }{labelValues}) 37 fake.recordInvocation("With", []interface{}{labelValues}) 38 fake.withMutex.Unlock() 39 if fake.WithStub != nil { 40 return fake.WithStub(labelValues...) 41 } 42 if specificReturn { 43 return ret.result1 44 } 45 return fake.withReturns.result1 46 } 47 48 func (fake *Histogram) WithCallCount() int { 49 fake.withMutex.RLock() 50 defer fake.withMutex.RUnlock() 51 return len(fake.withArgsForCall) 52 } 53 54 func (fake *Histogram) WithArgsForCall(i int) []string { 55 fake.withMutex.RLock() 56 defer fake.withMutex.RUnlock() 57 return fake.withArgsForCall[i].labelValues 58 } 59 60 func (fake *Histogram) WithReturns(result1 metrics.Histogram) { 61 fake.WithStub = nil 62 fake.withReturns = struct { 63 result1 metrics.Histogram 64 }{result1} 65 } 66 67 func (fake *Histogram) WithReturnsOnCall(i int, result1 metrics.Histogram) { 68 fake.WithStub = nil 69 if fake.withReturnsOnCall == nil { 70 fake.withReturnsOnCall = make(map[int]struct { 71 result1 metrics.Histogram 72 }) 73 } 74 fake.withReturnsOnCall[i] = struct { 75 result1 metrics.Histogram 76 }{result1} 77 } 78 79 func (fake *Histogram) Observe(value float64) { 80 fake.observeMutex.Lock() 81 fake.observeArgsForCall = append(fake.observeArgsForCall, struct { 82 value float64 83 }{value}) 84 fake.recordInvocation("Observe", []interface{}{value}) 85 fake.observeMutex.Unlock() 86 if fake.ObserveStub != nil { 87 fake.ObserveStub(value) 88 } 89 } 90 91 func (fake *Histogram) ObserveCallCount() int { 92 fake.observeMutex.RLock() 93 defer fake.observeMutex.RUnlock() 94 return len(fake.observeArgsForCall) 95 } 96 97 func (fake *Histogram) ObserveArgsForCall(i int) float64 { 98 fake.observeMutex.RLock() 99 defer fake.observeMutex.RUnlock() 100 return fake.observeArgsForCall[i].value 101 } 102 103 func (fake *Histogram) Invocations() map[string][][]interface{} { 104 fake.invocationsMutex.RLock() 105 defer fake.invocationsMutex.RUnlock() 106 fake.withMutex.RLock() 107 defer fake.withMutex.RUnlock() 108 fake.observeMutex.RLock() 109 defer fake.observeMutex.RUnlock() 110 copiedInvocations := map[string][][]interface{}{} 111 for key, value := range fake.invocations { 112 copiedInvocations[key] = value 113 } 114 return copiedInvocations 115 } 116 117 func (fake *Histogram) recordInvocation(key string, args []interface{}) { 118 fake.invocationsMutex.Lock() 119 defer fake.invocationsMutex.Unlock() 120 if fake.invocations == nil { 121 fake.invocations = map[string][][]interface{}{} 122 } 123 if fake.invocations[key] == nil { 124 fake.invocations[key] = [][]interface{}{} 125 } 126 fake.invocations[key] = append(fake.invocations[key], args) 127 } 128 129 var _ metrics.Histogram = new(Histogram)