// Run dispatches stored observations to the Analyzer per each
// ObservationMetadata key if threshold and dispatch frequency are met. If the
// criteria is not met, dispatcher goes back to wait mode until the next
// dispatch attempt.
//
// The underlying grpc connection to analyzer is closed when the dispatcher
// goes to sleep mode.
Run dispatches stored observations to the Analyzer per each
ObservationMetadata key if threshold and dispatch frequency are met. If the
criteria is not met, dispatcher goes back to wait mode until the next
dispatch attempt.

The underlying grpc connection to analyzer is closed when the dispatcher
goes to sleep mode.
// Run dispatches stored observations to the Analyzer per each // ObservationMetadata key if threshold and dispatch frequency are met . If the // criteria is not met dispatcher goes back to wait mode until the next // dispatch attempt . // // The underlying grpc connection to analyzer is closed when the dispatcher // goes to sleep mode .
func (d *Dispatcher) Run() {
	for {
		waitTime := d.computeWaitTime(time.Now())
		shouldDisconnectWhileSleeping := true
		if waitTime <= minWaitTime {
			waitTime = minWaitTime
			shouldDisconnectWhileSleeping = false
		}
		if shouldDisconnectWhileSleeping {
			glog.V(3).Infoln("Close existing connection to Analyzer...")
			d.analyzerTransport.close()
		}
		glog.V(5).Infof("Dispatcher sleeping for [%v]...", waitTime)
		time.Sleep(waitTime)
		if shouldDisconnectWhileSleeping {
			glog.V(3).Infoln("Re-establish grpc connection to Analyzer before the next dispatch...")
			d.analyzerTransport.reconnect()
		}
		d.lastDispatchTime = time.Now()
		d.dispatch(dispatchDelay)
	}
}
func ( d * Dispatcher ) Run ( ) { for { waitTime := d . computeWaitTime ( time . Now ( ) ) shouldDisconnectWhileSleeping := true if waitTime <= minWaitTime { waitTime = minWaitTime shouldDisconnectWhileSleeping = false } if shouldDisconnectWhileSleeping { glog . V ( 3 ) . Infoln ( " " ) d . analyzerTransport . close ( ) } glog . V ( 5 ) . Infof ( " " , waitTime ) time . Sleep ( waitTime ) if shouldDisconnectWhileSleeping { glog . V ( 3 ) . Infoln ( " " ) d . analyzerTransport . reconnect ( ) } d . lastDispatchTime = time . Now ( ) d . dispatch ( dispatchDelay ) } }
Run dispatches stored observations to the Analyzer per each
ObservationMetadata key if threshold and dispatch frequency are met.
Run dispatches stored observations to the Analyzer per each ObservationMetadata key if threshold and dispatch frequency are met .
// Don't bother disconnecting and reconnecting for a 3 second sleep.