// done iterates through all error channels, duplicating sending the error
// to inform callers that the rescan finished (or could not complete due
// to an error).
439978
func (b *rescanBatch) done(err error) {
	for _, c := range b.errChans {
		c <- err
	}
}
680249
func (w *SSTFileWriter) Finish() error {
	var cErr *C.char
	C.rocksdb_sstfilewriter_finish(w.c, &cErr)
	if cErr != nil {
		defer C.free(unsafe.Pointer(cErr))
		return errors.New(C.GoString(cErr))
	}
	return nil
}
381113
func (gs *Server) FinishRoutine() {
	gs.wg.Done()
	atomic.AddInt32(&gs.routinesCount, -1)
}
547104
func (l *LocalFile) Done() {
	l.Close()
	if l.unlink {
		os.Remove(l.Name())
	}
}
1015397
func (ch *Chunk) Done() {
	if !ch.IsFullyRead() {
		ch.Drain()
	}
	if ch.Wg != nil {
		ch.Wg.Done()
	}
}
1119330
func (b *GroupingBuilder) Done() Grouping {
	if len(b.g.groups) == 0 {
		return new(groupedTable)
	}
	g := b.g
	b.g = groupedTable{}
	return &g
}
393810
func (j *Job) Done() {
	j.mu.Lock()
	defer j.mu.Unlock()

	if j.conn == nil || j.pool == nil {
		// already marked as done
		return
	}

	var ok bool
	// Swallow this error because we don't want an unlock failure to cause work to
	// stop.
	_ = j.conn.QueryRow("que_unlock_job", j.ID).Scan(&ok)

	j.pool.Release(j.conn)
	j.pool = nil
	j.conn = nil
}
296155
func (r *ForwarderRequest) Complete(sendReset bool) {
	r.mu.Lock()
	defer r.mu.Unlock()

	if r.segment == nil {
		panic("Completing already completed forwarder request")
	}

	// Remove request from the forwarder.
	r.forwarder.mu.Lock()
	delete(r.forwarder.inFlight, r.segment.id)
	r.forwarder.mu.Unlock()

	// If the caller requested, send a reset.
	if sendReset {
		replyWithReset(r.segment)
	}

	// Release all resources.
	r.segment.decRef()
	r.segment = nil
	r.forwarder = nil
}
915977
func (r *Request) Do() error {
	err := r.send()
	if err != nil {
		return err
	}

	err = r.unpack()
	if err != nil {
		return err
	}
	return nil
}
323699
func (l *Client) Do(r *http.Request, response, data interface{}) error {
	// make the request

	res, err := l.client.Do(r)
	if err != nil {
		return err
	}
	defer res.Body.Close()

	// get the response
	b, err := ioutil.ReadAll(res.Body)
	if err != nil {
		return err
	}

	// if we have some struct to unmarshal body into, do that and return
	if response != nil {
		err = buildRespJSON(b, response, data)
		if err != nil {
			return err
		}
		switch rt := response.(type) {
		case *ApiResp:
			// if we have an invalid response code error out
			if res.StatusCode >= 301 {
				return fmt.Errorf(rt.Message)
			}
		}
	}

	// if we have an invalid response code error out
	if res.StatusCode >= 301 {
		return fmt.Errorf("Received non-successful response: %d", res.StatusCode)
	}

	return nil
}
562332
func (d *decoder) finished() bool {
	return d.br.finished() && d.dt[d.state].nbBits > 0
}
473939
func (op *LeaveScopeOperation) Done(err error) error {
	if err != nil {
		if !op.Force {
			return errors.Annotatef(err, "%v cannot leave scope", op.Description())
		}
		op.AddError(errors.Errorf("%v tried to forcefully leave scope but proceeded despite encountering ERROR %v", op.Description(), err))
	}
	return nil
}
1110251
func (c *AccountNotificationsClient) Done() {
	go func() {
		for range c.C {
		}
	}()
	go func() {
		s := c.server
		s.mu.Lock()
		clients := s.accountClients
		for i, ch := range clients {
			if c.C == ch {
				clients[i] = clients[len(clients)-1]
				s.accountClients = clients[:len(clients)-1]
				close(ch)
				break
			}
		}
		s.mu.Unlock()
	}()
}
724933
func (l *TimedLooper) Done(err error) {
	if l.DoneChan != nil {
		l.DoneChan <- err
	}
}
350551
func (b *Builder) Done() *Table {
	if len(b.t.colNames) == 0 {
		return new(Table)
	}
	t := b.t
	b.t = Table{}
	return &t
}
1361803
func (ta *Table) Done() {
	if !ta.HasPrimary() {
		return
	}
	pkIndex := ta.Indexes[0]
	ta.PKColumns = make([]int, len(pkIndex.Columns))
	for i, pkCol := range pkIndex.Columns {
		ta.PKColumns[i] = ta.FindColumn(pkCol)
	}
}
384025
func (t *compactionTracker) Attempted(level compactionLevel, success bool, duration time.Duration) {
	if success {
		atomic.AddUint64(&t.ok[level], 1)

		labels := t.Labels(level)

		t.metrics.CompactionDuration.With(labels).Observe(duration.Seconds())

		labels["status"] = "ok"
		t.metrics.Compactions.With(labels).Inc()

		return
	}

	atomic.AddUint64(&t.errors[level], 1)

	labels := t.Labels(level)
	labels["status"] = "error"
	t.metrics.Compactions.With(labels).Inc()
}