code: func (c *Coordinate) batchApplyUpdates() error {
  	// Grab the pending updates and release the lock so we can still handle
  	// incoming messages.
  	c.updatesLock.Lock()
  	pending := c.updates
  	c.updates = make(map[string]*structs.CoordinateUpdateRequest)
  	c.updatesLock.Unlock()
  
  	// Enforce the rate limit.
  	limit := c.srv.config.CoordinateUpdateBatchSize * c.srv.config.CoordinateUpdateMaxBatches
  	size := len(pending)
  	if size > limit {
  		c.srv.logger.Printf("[WARN] consul.coordinate: Discarded %d coordinate updates", size-limit)
  		size = limit
  	}
  
  	// Transform the map into a slice that we can feed to the Raft log in
  	// batches.
  	i := 0
  	updates := make(structs.Coordinates, size)
  	for _, update := range pending {
  		if !(i < size) {
  			break
  		}
  
  		updates[i] = &structs.Coordinate{
  			Node:    update.Node,
  			Segment: update.Segment,
  			Coord:   update.Coord,
  		}
  		i++
  	}
  
  	// Apply the updates to the Raft log in batches.
  	for start := 0; start < size; start += c.srv.config.CoordinateUpdateBatchSize {
  		end := start + c.srv.config.CoordinateUpdateBatchSize
  		if end > size {
  			end = size
  		}
  
  		// We set the "safe to ignore" flag on this update type so old
  		// servers don't crash if they see one of these.
  		t := structs.CoordinateBatchUpdateType | structs.IgnoreUnknownTypeFlag
  
  		slice := updates[start:end]
  		resp, err := c.srv.raftApply(t, slice)
  		if err != nil {
  			return err
  		}
  		if respErr, ok := resp.(error); ok {
  			return respErr
  		}
  	}
  	return nil
  }
docs: // batchApplyUpdates applies all pending updates to the Raft log in a series of
  // batches.