// readQueue is a method for reading from queue:
readQueue is a method for reading from queue.
// readQueue is a method for reading from queue :
func (adapter *Adapter) readQueue() {
	defer func(begin time.Time) {
		adapter.instrumenting.fireAddRequestCount(readQueueActionLabel)
		adapter.instrumenting.fireAddRequestLatency(begin, readQueueActionLabel)
	}(time.Now())
	buffer := make([]Line, 0)
	bufferSize := 0
	timeout := time.NewTimer(adapter.Config.FlushInterval)
	for {
		select {
		case msg := <-adapter.Queue:
			if bufferSize >= int(adapter.Config.MaxBufferSize) {
				timeout.Stop()
				adapter.flushBuffer(buffer)
				buffer = make([]Line, 0)
				bufferSize = 0
			}
			buffer = append(buffer, msg)
			bufferSize += len(msg.Line)
		case <-timeout.C:
			if bufferSize > 0 {
				adapter.flushBuffer(buffer)
				buffer = make([]Line, 0)
				bufferSize = 0
			}
		}
		timeout.Reset(adapter.Config.FlushInterval)
	}
}
func ( adapter * Adapter ) readQueue ( ) { defer func ( begin time . Time ) { adapter . instrumenting . fireAddRequestCount ( readQueueActionLabel ) adapter . instrumenting . fireAddRequestLatency ( begin , readQueueActionLabel ) } ( time . Now ( ) ) buffer := make ( [ ] Line , 0 ) bufferSize := 0 timeout := time . NewTimer ( adapter . Config . FlushInterval ) for { select { case msg := <- adapter . Queue : if bufferSize >= int ( adapter . Config . MaxBufferSize ) { timeout . Stop ( ) adapter . flushBuffer ( buffer ) buffer = make ( [ ] Line , 0 ) bufferSize = 0 } buffer = append ( buffer , msg ) bufferSize += len ( msg . Line ) case <- timeout . C : if bufferSize > 0 { adapter . flushBuffer ( buffer ) buffer = make ( [ ] Line , 0 ) bufferSize = 0 } } timeout . Reset ( adapter . Config . FlushInterval ) } }
readQueue is a method for reading from queue.
readQueue is a method for reading from queue .