Exemplo n.º 1
0
 /**
  * @param array    $users
  * @param \Closure $callback
  *
  * @return \float[]
  */
 public function batchUpdate(array $users, \Closure $callback = null)
 {
     $count = count($users);
     if ($count === 0) {
         return [];
     }
     $esUserList = $this->sanitizeData($users);
     $this->lastRoundData = $esUserList;
     $deltaList = [];
     while ($batch = array_splice($esUserList, 0, $this->batchSize)) {
         $start = microtime(true);
         $errorString = '';
         $success = $this->repo->burst($batch, $errorString);
         if (!$success) {
             $this->batchResult[] = $errorString;
         }
         $delta = microtime(true) - $start;
         $deltaList[] = $delta;
         if (is_callable($callback)) {
             call_user_func($callback, count($batch), $delta);
         }
     }
     return $deltaList;
 }