Exemple #1
0
func newDelayingQueue(clock clock.Clock) DelayingInterface {
	ret := &delayingType{
		Interface:          New(),
		clock:              clock,
		heartbeat:          clock.Tick(maxWait),
		stopCh:             make(chan struct{}),
		waitingTimeByEntry: map[t]time.Time{},
		waitingForAddCh:    make(chan waitFor, 1000),
	}

	go ret.waitingLoop()

	return ret
}
Exemple #2
0
// newExecWorker is a constructor for execWorker.
func newExecWorker(probeCmd, probePath string, execPeriod time.Duration, exec utilexec.Interface, clock clock.Clock, readyCh chan<- struct{}) *execWorker {
	return &execWorker{
		// Initializing the result with a timestamp here allows us to
		// wait maxLatency for the worker goroutine to start, and for each
		// iteration of the worker to complete.
		exec:      exec,
		clock:     clock,
		result:    execResult{[]byte{}, nil, clock.Now()},
		period:    execPeriod,
		probeCmd:  probeCmd,
		probePath: probePath,
		stopCh:    make(chan struct{}),
		readyCh:   readyCh,
	}
}
Exemple #3
0
func sinceInMicroseconds(clock clock.Clock, start time.Time) float64 {
	return float64(clock.Since(start).Nanoseconds() / time.Microsecond.Nanoseconds())
}