// Drains messages and errors, ensures the claim is fully closed.
18647
func (c *consumerGroupClaim) waitClosed() (errs ConsumerErrors) {
	go func() {
		for range c.Messages() {
		}
	}()

	for err := range c.Errors() {
		errs = append(errs, err)
	}
	return
}
1002744
func (me *Engine) Close() {
	me.mu.Lock()
	defer me.mu.Unlock()
	if !me.isOpen {
		return
	}
	me.isOpen = false
	me.se.UnregisterNotifier("messages")
	for _, mm := range me.managers {
		mm.Close()
	}
	me.managers = make(map[string]*messageManager)
	me.conns.Close()
}
641994
func (u *UserInfo) Claims(v interface{}) error {
	if u.claims == nil {
		return errors.New("oidc: claims not set")
	}
	return json.Unmarshal(u.claims, v)
}
1040047
func (b *Broker) StopConsuming() {
	// Do not retry from now on
	b.retry = false
	// Stop the retry closure earlier
	select {
	case b.retryStopChan <- 1:
		log.WARNING.Print("Stopping retry closure.")
	default:
	}
	// Notifying the stop channel stops consuming of messages
	select {
	case b.stopChan <- 1:
		log.WARNING.Print("Stop channel")
	default:
	}
}
1353619
func Wrap(err error, message string) error {
	if err == nil {
		return nil
	}
	err = &withMessage{
		cause: err,
		msg:   message,
	}
	return &withStack{
		err,
		callers(),
	}
}
778390
func ChannelClose(ch chan *Message) bool {
	select {
	case _, ok := <-ch:
		if ok {
			close(ch)
			return true
		}
	default:
	}
	return false
}
508746
func (ctrl *PersistentVolumeController) deleteClaim(claim *v1.PersistentVolumeClaim) {
	_ = ctrl.claims.Delete(claim)
	klog.V(4).Infof("claim %q deleted", claimToClaimKey(claim))

	volumeName := claim.Spec.VolumeName
	if volumeName == "" {
		klog.V(5).Infof("deleteClaim[%q]: volume not bound", claimToClaimKey(claim))
		return
	}
	// sync the volume when its claim is deleted.  Explicitly sync'ing the
	// volume here in response to claim deletion prevents the volume from
	// waiting until the next sync period for its Release.
	klog.V(5).Infof("deleteClaim[%q]: scheduling sync of volume %s", claimToClaimKey(claim), volumeName)
	ctrl.volumeQueue.Add(volumeName)
}
776468
func (b *PositionsService) Claim(positionId int, amount string) (Position, error) {

	request := map[string]interface{}{
		"position_id": positionId,
		"amount":      amount,
	}

	req, err := b.client.newAuthenticatedRequest("POST", "position/claim", request)

	if err != nil {
		return Position{}, err
	}

	var position = &Position{}

	_, err = b.client.do(req, position)

	if err != nil {
		return Position{}, err
	}

	return *position, nil
}
397218
func drainVMsAsync(c context.Context) error {
	return trigger(c, &tasks.DrainVM{}, datastore.NewQuery(model.VMKind))
}
255512
func TitanicClose() {
	worker, _ := mdapi.NewMdwrk("tcp://localhost:5555", "titanic.close", false)

	ok := []string{"200"}
	reply := []string{}
	for {
		request, err := worker.Recv(reply)
		if err != nil {
			break //  Interrupted, exit
		}

		uuid := request[0]
		os.Remove(RequestFilename(uuid))
		os.Remove(ReplyFilename(uuid))

		reply = ok
	}

}
431942
func (writer *ConsoleWriter) Close() {
	writer.lock.Lock()
	defer writer.lock.Unlock()

	if writer.closed {
		return
	}

	writer.blog.flush()
	writer.blog = nil
	writer.closed = true
}
578688
func (conn *ProtectedConn) Close() (err error) {
	conn.mutex.Lock()
	defer conn.mutex.Unlock()

	if !conn.isClosed {
		conn.isClosed = true
		if conn.Conn == nil {
			if conn.socketFd == socketError {
				err = nil
			} else {
				err = syscall.Close(conn.socketFd)
				// update socket fd to socketError
				// to make it explicit this connection
				// has been closed
				conn.socketFd = socketError
			}
		} else {
			err = conn.Conn.Close()
		}
	}
	return err
}
969083
func LogErrorsWhenClosing(in io.Closer) func() {
	return func() {
		err := in.Close()
		if err != nil {
			log.Error(err)
		}
	}
}
1086606
func (c claim) respond(err error) {
	select {
	case <-c.stop:
	case c.response <- err:
	}
}
396148
func Drain(ch interface{}) {
	chValue := reflect.ValueOf(ch)
	for {
		_, ok := chValue.Recv()
		if !ok {
			break
		}
	}
}
861451
func (r *RingLogger) Close() error {
	r.setClosed()
	r.buffer.Close()
	// empty out the queue
	var logErr bool
	for _, msg := range r.buffer.Drain() {
		if logErr {
			// some error logging a previous message, so re-insert to message pool
			// and assume log driver is hosed
			PutMessage(msg)
			continue
		}

		if err := r.l.Log(msg); err != nil {
			logrus.WithField("driver", r.l.Name()).
				WithField("container", r.logInfo.ContainerID).
				WithError(err).
				Errorf("Error writing log message")
			logErr = true
		}
	}
	return r.l.Close()
}
672473
func (r *RingLogger) Log(msg *Message) error {
	if r.closed() {
		return errClosed
	}
	return r.buffer.Enqueue(msg)
}