// Clock allows you to fake che CircuitBreaker's view of the current time.
// Intended for unit tests.
962931
func Clock(clock timetools.TimeProvider) CircuitBreakerOption {
	return func(c *CircuitBreaker) error {
		c.clock = clock
		return nil
	}
}
1361258
func Clock(c clock.Clock) Option {
	return func(r *Ringpop) error {
		if c == nil {
			return errors.New("clock is required")
		}
		r.clock = c
		return nil
	}
}
255473
func (u *Updater) ensureClock() (time.Time, error) {
	coll, closer := u.collection()
	defer closer()

	// Read the existing clock document if it's there, initialising
	// it with a zero time otherwise.
	var doc clockDoc
	if _, err := coll.FindId(clockDocID).Apply(mgo.Change{
		// We can't use $set here, as otherwise we'll
		// overwrite an existing document.
		Update: bson.D{{"$inc", bson.D{{"time", 0}}}},
		Upsert: true,
	}, &doc); err != nil {
		return time.Time{}, errors.Annotate(err, "upserting clock document")
	}
	return doc.time(), nil
}
792245
func CurrentTime(tp uint8) Time {
	return Time{Time: FromGoTime(gotime.Now()), Type: tp, Fsp: 0}
}
1069738
func (formatter *Formatter) Time(format string) string {
	return formatter.Event.Time.Format(format)
}
850852
func (tr Row) Time(nn int, loc *time.Location) (val time.Time) {
	val, err := tr.TimeErr(nn, loc)
	if err != nil {
		panic(err)
	}
	return
}
767003
func (a *AuthContext) WithClock(clock clock.Clock) *AuthContext {
	ctxtCopy := *a
	ctxtCopy.clock = clock
	return &ctxtCopy
}
144676
func (RealClock) Timer(d time.Duration) Timer {
	return &realTimer{t: time.NewTimer(d)}
}
662539
func (timestamp *Timestamp) Time() time.Time {
	return time.Date(timestamp.Year, time.Month(timestamp.Month), timestamp.Day,
		timestamp.Hour, timestamp.Min, timestamp.Sec, timestamp.NanoSec, time.UTC)
}
38385
func CounterClock(c timetools.TimeProvider) rcOptSetter {
	return func(r *RollingCounter) error {
		r.clock = c
		return nil
	}
}
1292991
func (f *FakeClock) Now() time.Time {
	f.lock.RLock()
	defer f.lock.RUnlock()
	return f.time
}
754814
func (cb *CircuitBreaker) State() State {
	cb.mutex.Lock()
	defer cb.mutex.Unlock()

	now := time.Now()
	state, _ := cb.currentState(now)
	return state
}
664746
func Time(t time.Time) NullTime {
	return NullTime{
		pq.NullTime{
			Time:  t,
			Valid: true,
		},
	}
}
656797
func Clock(clock timetools.TimeProvider) TokenLimiterOption {
	return func(cl *TokenLimiter) error {
		cl.clock = clock
		return nil
	}
}
1067022
func (fc *fakeClock) Now() time.Time {
	fc.l.RLock()
	t := fc.time
	fc.l.RUnlock()
	return t
}
1244838
func (m *Mock) Timer(d time.Duration) *Timer {
	m.mu.Lock()
	defer m.mu.Unlock()
	ch := make(chan time.Time, 1)
	t := &Timer{
		C:       ch,
		c:       ch,
		mock:    m,
		next:    m.now.Add(d),
		stopped: false,
	}
	m.timers = append(m.timers, (*internalTimer)(t))
	return t
}
875326
func GetClock() Clock {
	if !flag.Parsed() {
		panic("GetClock() called before flags are parsed")
	}

	c, ok := clockTypes[*defaultClockType]
	if !ok {
		log.Fatalf("No Clock type named %v", *defaultClockType)
	}
	return c
}