// NewMockBackoff creates a new mock of the Backoff interface. All methods
// return zero values for all results, unless overwritten.
176710
func NewMockBackoff() *MockBackoff {
	return &MockBackoff{
		CloneFunc: &BackoffCloneFunc{
			defaultHook: func() backoff.Backoff {
				return nil
			},
		},
		NextIntervalFunc: &BackoffNextIntervalFunc{
			defaultHook: func() time.Duration {
				return 0
			},
		},
		ResetFunc: &BackoffResetFunc{
			defaultHook: func() {
				return
			},
		},
	}
}
1281636
func NewMockUnit(ctrl *gomock.Controller) *MockUnit {
	mock := &MockUnit{ctrl: ctrl}
	mock.recorder = &MockUnitMockRecorder{mock}
	return mock
}
404708
func NewBackoffer(ctx context.Context, maxSleep int) *Backoffer {
	return &Backoffer{
		ctx:      ctx,
		maxSleep: maxSleep,
		vars:     kv.DefaultVars,
	}
}
864859
func NewMockEnforcer(ctrl *gomock.Controller) *MockEnforcer {
	mock := &MockEnforcer{ctrl: ctrl}
	mock.recorder = &MockEnforcerMockRecorder{mock}
	return mock
}
873583
func NewMockSession(ctrl *gomock.Controller) *MockSession {
	mock := &MockSession{ctrl: ctrl}
	mock.recorder = &MockSessionMockRecorder{mock}
	return mock
}
493536
func NewMock(req *Request, res *Response) *Mocker {
	mock := &Mocker{
		request:  req,
		response: res,
		matcher:  DefaultMatcher,
	}
	res.Mock = mock
	req.Mock = mock
	req.Response = res
	return mock
}
79574
func NewMockOperation(ctrl *gomock.Controller) *MockOperation {
	mock := &MockOperation{ctrl: ctrl}
	mock.recorder = &MockOperationMockRecorder{mock}
	return mock
}
1220815
func NewMockConn(ctrl *gomock.Controller) *MockConn {
	mock := &MockConn{ctrl: ctrl}
	mock.recorder = &MockConnMockRecorder{mock}
	return mock
}
872279
func NewMockLogger(ctrl *gomock.Controller) *MockLogger {
	mock := &MockLogger{ctrl: ctrl}
	mock.recorder = &MockLoggerMockRecorder{mock}
	return mock
}
177937
func NewMockIndex(ctrl *gomock.Controller) *MockIndex {
	mock := &MockIndex{ctrl: ctrl}
	mock.recorder = &MockIndexMockRecorder{mock}
	return mock
}
1024826
func NewBackoffFn(base, cap, jitter int) func(ctx context.Context) int {
	if base < 2 {
		// Top prevent panic in 'rand.Intn'.
		base = 2
	}
	attempts := 0
	lastSleep := base
	return func(ctx context.Context) int {
		var sleep int
		switch jitter {
		case NoJitter:
			sleep = expo(base, cap, attempts)
		case FullJitter:
			v := expo(base, cap, attempts)
			sleep = rand.Intn(v)
		case EqualJitter:
			v := expo(base, cap, attempts)
			sleep = v/2 + rand.Intn(v/2)
		case DecorrJitter:
			sleep = int(math.Min(float64(cap), float64(base+rand.Intn(lastSleep*3-base))))
		}
		logutil.Logger(context.Background()).Debug("backoff",
			zap.Int("base", base),
			zap.Int("sleep", sleep))
		select {
		case <-time.After(time.Duration(sleep) * time.Millisecond):
		case <-ctx.Done():
		}

		attempts++
		lastSleep = sleep
		return lastSleep
	}
}
160067
func NewMock(opts ...ConnectOpts) *Mock {
	m := &Mock{
		ExpectedQueries: make([]*MockQuery, 0),
		Queries:         make([]MockQuery, 0),
	}

	if len(opts) > 0 {
		m.opts = opts[0]
	}

	return m
}
504625
func NewMockBuilder(ctrl *gomock.Controller) *MockBuilder {
	mock := &MockBuilder{ctrl: ctrl}
	mock.recorder = &MockBuilderMockRecorder{mock}
	return mock
}
703444
func NewMockRemoteBindingListener(ctrl *gomock.Controller) *MockRemoteBindingListener {
	mock := &MockRemoteBindingListener{ctrl: ctrl}
	mock.recorder = &MockRemoteBindingListenerMockRecorder{mock}
	return mock
}
1027239
func NewMockPacketEncoder(ctrl *gomock.Controller) *MockPacketEncoder {
	mock := &MockPacketEncoder{ctrl: ctrl}
	mock.recorder = &MockPacketEncoderMockRecorder{mock}
	return mock
}
921451
func nextBackoff(backoff float64) float64 {
	if backoff < 0.5 {
		backoff = 0.5
	}

	backoff = backoff * 1.15 * (1.0 + rand.Float64())
	if backoff > 120 {
		backoff = 120
	} else if backoff < 0.5 {
		backoff = 0.5
	}

	return backoff
}
408252
func NewMock() Mock {
	return &mock{
		base:  time.Now(),
		setAt: time.Now(),
		sleep: -1,
	}
}