storage/remote/queue_manager.go
func (s *shards) stop() {
	// Attempt a clean shutdown, but only wait flushDeadline for all the shards
	// to cleanly exit.  As we're doing RPCs, enqueue can block indefinitely.
	// We must be able so call stop concurrently, hence we can only take the
	// RLock here.
	s.mtx.RLock()
	close(s.softShutdown)
	s.mtx.RUnlock()

	// Enqueue should now be unblocked, so we can take the write lock.  This
	// also ensures we don't race with writes to the queues, and get a panic:
	// send on closed channel.
	s.mtx.Lock()
	defer s.mtx.Unlock()
	for _, queue := range s.queues {
		close(queue)
	}
	select {
	case <-s.done:
		return
	case <-time.After(s.qm.flushDeadline):
		level.Error(s.qm.logger).Log("msg", "Failed to flush all samples on shutdown")
	}

	// Force an unclean shutdown.
	s.hardShutdown()
	<-s.done
}
func (s *shards) stop() {
	// Attempt a clean shutdown, but only wait flushDeadline for all the shards
	// to cleanly exit.  As we're doing RPCs, enqueue can block indefinitely.
	// We must be able so call stop concurrently, hence we can only take the
	// RLock here.
	s.mtx.RLock()
	close(s.softShutdown)
	s.mtx.RUnlock()

	// Enqueue should now be unblocked, so we can take the write lock.  This
	// also ensures we don't race with writes to the queues, and get a panic:
	// send on closed channel.
	s.mtx.Lock()
	defer s.mtx.Unlock()
	for _, queue := range s.queues {
		close(queue)
	}
	select {
	case <-s.done:
		return
	case <-time.After(s.qm.flushDeadline):
		level.Error(s.qm.logger).Log("msg", "Failed to flush all samples on shutdown")
	}

	// Force an unclean shutdown.
	s.hardShutdown()
	<-s.done
}
func ( s * shards ) stop ( ) { // Attempt a clean shutdown, but only wait flushDeadline for all the shards // to cleanly exit.  As we're doing RPCs, enqueue can block indefinitely. // We must be able so call stop concurrently, hence we can only take the // RLock here. s . mtx . RLock ( ) close ( s . softShutdown ) s . mtx . RUnlock ( ) // Enqueue should now be unblocked, so we can take the write lock.  This // also ensures we don't race with writes to the queues, and get a panic: // send on closed channel. s . mtx . Lock ( ) defer s . mtx . Unlock ( ) for _ , queue := range s . queues { close ( queue ) } select { case <- s . done : return case <- time . After ( s . qm . flushDeadline ) : level . Error ( s . qm . logger ) . Log ( " " , " " ) } // Force an unclean shutdown. s . hardShutdown ( ) <- s . done }
// stop the shards; subsequent call to enqueue will return false.
stop the shards ; subsequent call to enqueue will return false .