コード例 #1
0
 public function testBatchingRequests()
 {
     // Test that operations that do not allow 'batching'
     $response = $this->client->import(['batch' => [['event' => 'foo', 'properties' => ['bar' => 'baz']]]]);
     $this->assertEquals(['success' => true], $response);
     // Test that operations that allow 'batching'
     $response = $this->client->track(['event' => 'foo', 'properties' => ['bar' => 'baz']]);
     $this->assertEquals(['success' => true, 'batched' => true], $response);
 }
コード例 #2
0
 /**
  * Flushes the queue by batching Import operations
  *
  * @return boolean
  */
 public function flush()
 {
     if (empty($this->queue)) {
         return false;
     }
     $operations = array_chunk($this->queue, $this->batchSize);
     foreach ($operations as $batch) {
         $this->client->import(['batch' => $batch]);
     }
     return true;
 }