Skip to content

Commit

Permalink
Updates for batches, where the batch quantity is less than 10
Browse files Browse the repository at this point in the history
  • Loading branch information
turbo124 committed Jan 29, 2023
1 parent 05d8d24 commit 72b2b45
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/CollectorServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function register()
/* Register the scheduler */
$this->app->booted(function () {
$schedule = app(Schedule::class);
$schedule->job(new BatchMetrics())->everyFiveMinutes();
$schedule->job(new BatchMetrics())->everyFiveMinutes()->withoutOverlapping()->name('beacon-batch-job')->onOneServer();
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/ForceSend.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function handle()

}

BatchMetrics::dispatchNow();
(new BatchMetrics())->handle();

$this->logMessage(date('Y-m-d h:i:s') . ' Sent Data!!');

Expand Down
9 changes: 1 addition & 8 deletions src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ public function batchFire($metric_array)
$batch_of = 40;
$batch = array_chunk($metric_array, $batch_of);

$x = 1;

/* Concurrency ++ */
foreach($batch as $key => $value) {

Expand All @@ -113,12 +111,7 @@ public function batchFire($metric_array)
$key => $client->requestAsync('POST',$this->endPoint($metric_array[0]->type), ['form_params' => $data])
];

$x++;

if($x >= 10) {
$x = 1;
$this->sendPromise($promises);
}
$this->sendPromise($promises);

}

Expand Down

0 comments on commit 72b2b45

Please sign in to comment.