github.com/anjalikarhana/fabric@v2.1.1+incompatible/orderer/common/blockcutter/mock/metrics_histogram.go (about)

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