code: func (r *messageRing) Dequeue() (*Message, error) {
  	r.mu.Lock()
  	for len(r.queue) == 0 && !r.closed {
  		r.wait.Wait()
  	}
  
  	if r.closed {
  		r.mu.Unlock()
  		return nil, errClosed
  	}
  
  	msg := r.queue[0]
  	r.queue = r.queue[1:]
  	r.sizeBytes -= int64(len(msg.Line))
  	r.mu.Unlock()
  	return msg, nil
  }
docs: // Dequeue pulls a message off the queue
  // If there are no messages, it waits for one.
  // If the buffer is closed, it will return immediately.